feat(asset): 新增报修维修明细报表功能
- 创建 AmsRepairDetailReport 实体类,包含报修单号、资产信息、维修详情等字段 - 实现 AmsRepairDetailReportController 控制器,提供报表查询和导出功能 - 开发 AmsRepairDetailReportMapper 数据访问接口及对应的 XML 映射文件 - 实现 AmsRepairDetailReportService 业务逻辑层,处理报表数据查询逻辑 - 添加单元测试验证报表服务的功能正确性 - 创建前端页面模板实现报表查询界面和数据展示 - 定义 RepairOrderStatus 常量类规范维修单状态枚举值 - 实现权限控制和 Excel 导出功能main
parent
677c591024
commit
d4a5b4db79
@ -0,0 +1,31 @@
|
||||
package com.ruoyi.asset.constant;
|
||||
|
||||
/**
|
||||
* 维修单状态常量定义
|
||||
*
|
||||
* @author Yangk
|
||||
*/
|
||||
public final class RepairOrderStatus
|
||||
{
|
||||
/** 草稿 */
|
||||
public static final String DRAFT = "DRAFT";
|
||||
|
||||
/** 待确认 */
|
||||
public static final String PENDING_CONFIRM = "PENDING_CONFIRM";
|
||||
|
||||
/** 待维修 */
|
||||
public static final String WAIT_REPAIR = "WAIT_REPAIR";
|
||||
|
||||
/** 已驳回 */
|
||||
public static final String REJECTED = "REJECTED";
|
||||
|
||||
/** 维修中 */
|
||||
public static final String REPAIRING = "REPAIRING";
|
||||
|
||||
/** 已完成维修 */
|
||||
public static final String REPAIR_DONE = "REPAIR_DONE";
|
||||
|
||||
private RepairOrderStatus()
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
package com.ruoyi.asset.controller;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.asset.domain.AmsAssetCategory;
|
||||
import com.ruoyi.asset.domain.AmsRepairDetailReport;
|
||||
import com.ruoyi.asset.service.IAmsAssetCategoryService;
|
||||
import com.ruoyi.asset.service.IAmsRepairDetailReportService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
|
||||
/**
|
||||
* 报修维修明细报表Controller
|
||||
*
|
||||
* @author Yangk
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/asset/report/repair")
|
||||
public class AmsRepairDetailReportController extends BaseController
|
||||
{
|
||||
private static final String ENABLED_YES = "Y";
|
||||
|
||||
private String prefix = "asset/report";
|
||||
|
||||
@Autowired
|
||||
private IAmsRepairDetailReportService amsRepairDetailReportService;
|
||||
|
||||
@Autowired
|
||||
private IAmsAssetCategoryService amsAssetCategoryService;
|
||||
|
||||
@RequiresPermissions("asset:report:repair:view")
|
||||
@GetMapping()
|
||||
public String repair(ModelMap mmap)
|
||||
{
|
||||
mmap.put("categoryList", selectEnabledCategoryList());
|
||||
return prefix + "/repair";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询报修维修明细报表列表。
|
||||
*/
|
||||
@RequiresPermissions("asset:report:repair:list")
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo list(AmsRepairDetailReport amsRepairDetailReport)
|
||||
{
|
||||
startPage();
|
||||
List<AmsRepairDetailReport> list = amsRepairDetailReportService
|
||||
.selectRepairDetailReportList(amsRepairDetailReport);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出报修维修明细报表。
|
||||
*/
|
||||
@RequiresPermissions("asset:report:repair:export")
|
||||
@Log(title = "报修维修明细报表", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
@ResponseBody
|
||||
public AjaxResult export(AmsRepairDetailReport amsRepairDetailReport)
|
||||
{
|
||||
List<AmsRepairDetailReport> list = amsRepairDetailReportService
|
||||
.selectRepairDetailReportList(amsRepairDetailReport);
|
||||
ExcelUtil<AmsRepairDetailReport> util = new ExcelUtil<AmsRepairDetailReport>(AmsRepairDetailReport.class);
|
||||
return util.exportExcel(list, "报修维修明细报表数据");
|
||||
}
|
||||
|
||||
private List<AmsAssetCategory> selectEnabledCategoryList()
|
||||
{
|
||||
AmsAssetCategory category = new AmsAssetCategory();
|
||||
category.setEnabled(ENABLED_YES);
|
||||
return amsAssetCategoryService.selectAmsAssetCategoryList(category);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,343 @@
|
||||
package com.ruoyi.asset.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 报修维修明细报表对象
|
||||
*
|
||||
* @author Yangk
|
||||
*/
|
||||
public class AmsRepairDetailReport extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 报修单号 */
|
||||
@Excel(name = "报修单号")
|
||||
private String repairNo;
|
||||
|
||||
/** 资产编码 */
|
||||
@Excel(name = "资产编码")
|
||||
private String assetCode;
|
||||
|
||||
/** 资产名称 */
|
||||
@Excel(name = "资产名称")
|
||||
private String assetName;
|
||||
|
||||
/** 资产类别ID */
|
||||
private Long categoryId;
|
||||
|
||||
/** 资产类别 */
|
||||
@Excel(name = "资产类别")
|
||||
private String categoryName;
|
||||
|
||||
/** 规格型号 */
|
||||
@Excel(name = "规格型号")
|
||||
private String specModel;
|
||||
|
||||
/** 品牌 */
|
||||
@Excel(name = "品牌")
|
||||
private String brand;
|
||||
|
||||
/** 报修人 */
|
||||
@Excel(name = "报修人")
|
||||
private String reportUserName;
|
||||
|
||||
/** 故障描述 */
|
||||
@Excel(name = "故障描述")
|
||||
private String faultDesc;
|
||||
|
||||
/** 报修时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Excel(name = "报修时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date reportTime;
|
||||
|
||||
/** 预计完成时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Excel(name = "预计完成时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date expectedFinishTime;
|
||||
|
||||
/** 维修方类型 */
|
||||
@Excel(name = "维修方类型", dictType = "ams_repairer_type")
|
||||
private String repairerType;
|
||||
|
||||
/** 维修人 */
|
||||
@Excel(name = "维修人")
|
||||
private String repairUserName;
|
||||
|
||||
/** 维修单位 */
|
||||
@Excel(name = "维修单位")
|
||||
private String repairOrgName;
|
||||
|
||||
/** 维修联系电话 */
|
||||
@Excel(name = "维修联系电话")
|
||||
private String repairContactPhone;
|
||||
|
||||
/** 开始维修时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Excel(name = "开始维修时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date repairStartTime;
|
||||
|
||||
/** 维修完成时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Excel(name = "维修完成时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date repairFinishTime;
|
||||
|
||||
/** 维修结果 */
|
||||
@Excel(name = "维修结果")
|
||||
private String repairResult;
|
||||
|
||||
/** 维修费用 */
|
||||
@Excel(name = "维修费用")
|
||||
private BigDecimal repairCost;
|
||||
|
||||
/** 单据状态 */
|
||||
@Excel(name = "单据状态", dictType = "ams_repair_status")
|
||||
private String orderStatus;
|
||||
|
||||
/** 是否超期,仅用于报表查询过滤 */
|
||||
private String overdueFlag;
|
||||
|
||||
public void setRepairNo(String repairNo)
|
||||
{
|
||||
this.repairNo = repairNo;
|
||||
}
|
||||
|
||||
public String getRepairNo()
|
||||
{
|
||||
return repairNo;
|
||||
}
|
||||
|
||||
public void setAssetCode(String assetCode)
|
||||
{
|
||||
this.assetCode = assetCode;
|
||||
}
|
||||
|
||||
public String getAssetCode()
|
||||
{
|
||||
return assetCode;
|
||||
}
|
||||
|
||||
public void setAssetName(String assetName)
|
||||
{
|
||||
this.assetName = assetName;
|
||||
}
|
||||
|
||||
public String getAssetName()
|
||||
{
|
||||
return assetName;
|
||||
}
|
||||
|
||||
public void setCategoryId(Long categoryId)
|
||||
{
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public Long getCategoryId()
|
||||
{
|
||||
return categoryId;
|
||||
}
|
||||
|
||||
public void setCategoryName(String categoryName)
|
||||
{
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
public String getCategoryName()
|
||||
{
|
||||
return categoryName;
|
||||
}
|
||||
|
||||
public void setSpecModel(String specModel)
|
||||
{
|
||||
this.specModel = specModel;
|
||||
}
|
||||
|
||||
public String getSpecModel()
|
||||
{
|
||||
return specModel;
|
||||
}
|
||||
|
||||
public void setBrand(String brand)
|
||||
{
|
||||
this.brand = brand;
|
||||
}
|
||||
|
||||
public String getBrand()
|
||||
{
|
||||
return brand;
|
||||
}
|
||||
|
||||
public void setReportUserName(String reportUserName)
|
||||
{
|
||||
this.reportUserName = reportUserName;
|
||||
}
|
||||
|
||||
public String getReportUserName()
|
||||
{
|
||||
return reportUserName;
|
||||
}
|
||||
|
||||
public void setFaultDesc(String faultDesc)
|
||||
{
|
||||
this.faultDesc = faultDesc;
|
||||
}
|
||||
|
||||
public String getFaultDesc()
|
||||
{
|
||||
return faultDesc;
|
||||
}
|
||||
|
||||
public void setReportTime(Date reportTime)
|
||||
{
|
||||
this.reportTime = reportTime;
|
||||
}
|
||||
|
||||
public Date getReportTime()
|
||||
{
|
||||
return reportTime;
|
||||
}
|
||||
|
||||
public void setExpectedFinishTime(Date expectedFinishTime)
|
||||
{
|
||||
this.expectedFinishTime = expectedFinishTime;
|
||||
}
|
||||
|
||||
public Date getExpectedFinishTime()
|
||||
{
|
||||
return expectedFinishTime;
|
||||
}
|
||||
|
||||
public void setRepairerType(String repairerType)
|
||||
{
|
||||
this.repairerType = repairerType;
|
||||
}
|
||||
|
||||
public String getRepairerType()
|
||||
{
|
||||
return repairerType;
|
||||
}
|
||||
|
||||
public void setRepairUserName(String repairUserName)
|
||||
{
|
||||
this.repairUserName = repairUserName;
|
||||
}
|
||||
|
||||
public String getRepairUserName()
|
||||
{
|
||||
return repairUserName;
|
||||
}
|
||||
|
||||
public void setRepairOrgName(String repairOrgName)
|
||||
{
|
||||
this.repairOrgName = repairOrgName;
|
||||
}
|
||||
|
||||
public String getRepairOrgName()
|
||||
{
|
||||
return repairOrgName;
|
||||
}
|
||||
|
||||
public void setRepairContactPhone(String repairContactPhone)
|
||||
{
|
||||
this.repairContactPhone = repairContactPhone;
|
||||
}
|
||||
|
||||
public String getRepairContactPhone()
|
||||
{
|
||||
return repairContactPhone;
|
||||
}
|
||||
|
||||
public void setRepairStartTime(Date repairStartTime)
|
||||
{
|
||||
this.repairStartTime = repairStartTime;
|
||||
}
|
||||
|
||||
public Date getRepairStartTime()
|
||||
{
|
||||
return repairStartTime;
|
||||
}
|
||||
|
||||
public void setRepairFinishTime(Date repairFinishTime)
|
||||
{
|
||||
this.repairFinishTime = repairFinishTime;
|
||||
}
|
||||
|
||||
public Date getRepairFinishTime()
|
||||
{
|
||||
return repairFinishTime;
|
||||
}
|
||||
|
||||
public void setRepairResult(String repairResult)
|
||||
{
|
||||
this.repairResult = repairResult;
|
||||
}
|
||||
|
||||
public String getRepairResult()
|
||||
{
|
||||
return repairResult;
|
||||
}
|
||||
|
||||
public void setRepairCost(BigDecimal repairCost)
|
||||
{
|
||||
this.repairCost = repairCost;
|
||||
}
|
||||
|
||||
public BigDecimal getRepairCost()
|
||||
{
|
||||
return repairCost;
|
||||
}
|
||||
|
||||
public void setOrderStatus(String orderStatus)
|
||||
{
|
||||
this.orderStatus = orderStatus;
|
||||
}
|
||||
|
||||
public String getOrderStatus()
|
||||
{
|
||||
return orderStatus;
|
||||
}
|
||||
|
||||
public void setOverdueFlag(String overdueFlag)
|
||||
{
|
||||
this.overdueFlag = overdueFlag;
|
||||
}
|
||||
|
||||
public String getOverdueFlag()
|
||||
{
|
||||
return overdueFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("repairNo", getRepairNo())
|
||||
.append("assetCode", getAssetCode())
|
||||
.append("assetName", getAssetName())
|
||||
.append("categoryId", getCategoryId())
|
||||
.append("categoryName", getCategoryName())
|
||||
.append("specModel", getSpecModel())
|
||||
.append("brand", getBrand())
|
||||
.append("reportUserName", getReportUserName())
|
||||
.append("faultDesc", getFaultDesc())
|
||||
.append("reportTime", getReportTime())
|
||||
.append("expectedFinishTime", getExpectedFinishTime())
|
||||
.append("repairerType", getRepairerType())
|
||||
.append("repairUserName", getRepairUserName())
|
||||
.append("repairOrgName", getRepairOrgName())
|
||||
.append("repairContactPhone", getRepairContactPhone())
|
||||
.append("repairStartTime", getRepairStartTime())
|
||||
.append("repairFinishTime", getRepairFinishTime())
|
||||
.append("repairResult", getRepairResult())
|
||||
.append("repairCost", getRepairCost())
|
||||
.append("orderStatus", getOrderStatus())
|
||||
.append("overdueFlag", getOverdueFlag())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.ruoyi.asset.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.asset.domain.AmsRepairDetailReport;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 报修维修明细报表Mapper接口
|
||||
*
|
||||
* @author Yangk
|
||||
*/
|
||||
public interface AmsRepairDetailReportMapper
|
||||
{
|
||||
/**
|
||||
* 查询报修维修明细报表列表。
|
||||
*
|
||||
* @param report 查询条件
|
||||
* @param effectiveStatuses 已形成维修事实的单据状态
|
||||
* @return 报修维修明细报表集合
|
||||
*/
|
||||
public List<AmsRepairDetailReport> selectRepairDetailReportList(
|
||||
@Param("report") AmsRepairDetailReport report,
|
||||
@Param("effectiveStatuses") List<String> effectiveStatuses);
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.ruoyi.asset.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.asset.domain.AmsRepairDetailReport;
|
||||
|
||||
/**
|
||||
* 报修维修明细报表Service接口
|
||||
*
|
||||
* @author Yangk
|
||||
*/
|
||||
public interface IAmsRepairDetailReportService
|
||||
{
|
||||
/**
|
||||
* 查询报修维修明细报表列表。
|
||||
*
|
||||
* @param amsRepairDetailReport 报修维修明细报表查询条件
|
||||
* @return 报修维修明细报表集合
|
||||
*/
|
||||
public List<AmsRepairDetailReport> selectRepairDetailReportList(AmsRepairDetailReport amsRepairDetailReport);
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package com.ruoyi.asset.service.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.asset.constant.RepairOrderStatus;
|
||||
import com.ruoyi.asset.domain.AmsRepairDetailReport;
|
||||
import com.ruoyi.asset.mapper.AmsRepairDetailReportMapper;
|
||||
import com.ruoyi.asset.service.IAmsRepairDetailReportService;
|
||||
|
||||
/**
|
||||
* 报修维修明细报表Service业务层处理
|
||||
*
|
||||
* @author Yangk
|
||||
*/
|
||||
@Service
|
||||
public class AmsRepairDetailReportServiceImpl implements IAmsRepairDetailReportService
|
||||
{
|
||||
private static final List<String> EFFECTIVE_REPAIR_STATUSES = Collections.unmodifiableList(Arrays.asList(
|
||||
RepairOrderStatus.WAIT_REPAIR, RepairOrderStatus.REPAIRING, RepairOrderStatus.REPAIR_DONE));
|
||||
|
||||
@Autowired
|
||||
private AmsRepairDetailReportMapper amsRepairDetailReportMapper;
|
||||
|
||||
/**
|
||||
* 查询报修维修明细报表列表。
|
||||
*/
|
||||
@Override
|
||||
public List<AmsRepairDetailReport> selectRepairDetailReportList(AmsRepairDetailReport amsRepairDetailReport)
|
||||
{
|
||||
AmsRepairDetailReport query = amsRepairDetailReport == null ? new AmsRepairDetailReport()
|
||||
: amsRepairDetailReport;
|
||||
// 报表只统计已受理后的维修事实,排除草稿、待确认、驳回,避免过程申请数据污染报表口径。
|
||||
return amsRepairDetailReportMapper.selectRepairDetailReportList(query, EFFECTIVE_REPAIR_STATUSES);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,112 @@
|
||||
<?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="com.ruoyi.asset.mapper.AmsRepairDetailReportMapper">
|
||||
|
||||
<resultMap type="AmsRepairDetailReport" id="AmsRepairDetailReportResult">
|
||||
<result property="repairNo" column="repair_no"/>
|
||||
<result property="assetCode" column="asset_code"/>
|
||||
<result property="assetName" column="asset_name"/>
|
||||
<result property="categoryId" column="category_id"/>
|
||||
<result property="categoryName" column="category_name"/>
|
||||
<result property="specModel" column="spec_model"/>
|
||||
<result property="brand" column="brand"/>
|
||||
<result property="reportUserName" column="report_user_name"/>
|
||||
<result property="faultDesc" column="fault_desc"/>
|
||||
<result property="reportTime" column="report_time"/>
|
||||
<result property="expectedFinishTime" column="expected_finish_time"/>
|
||||
<result property="repairerType" column="repairer_type"/>
|
||||
<result property="repairUserName" column="repair_user_name"/>
|
||||
<result property="repairOrgName" column="repair_org_name"/>
|
||||
<result property="repairContactPhone" column="repair_contact_phone"/>
|
||||
<result property="repairStartTime" column="repair_start_time"/>
|
||||
<result property="repairFinishTime" column="repair_finish_time"/>
|
||||
<result property="repairResult" column="repair_result"/>
|
||||
<result property="repairCost" column="repair_cost"/>
|
||||
<result property="orderStatus" column="order_status"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="repairDetailReportColumns">
|
||||
repair_no,
|
||||
asset_code,
|
||||
asset_name,
|
||||
category_id,
|
||||
category_name,
|
||||
spec_model,
|
||||
brand,
|
||||
report_user_name,
|
||||
fault_desc,
|
||||
report_time,
|
||||
expected_finish_time,
|
||||
repairer_type,
|
||||
repair_user_name,
|
||||
repair_org_name,
|
||||
repair_contact_phone,
|
||||
repair_start_time,
|
||||
repair_finish_time,
|
||||
repair_result,
|
||||
repair_cost,
|
||||
order_status
|
||||
</sql>
|
||||
|
||||
<sql id="repairDetailReportWhere">
|
||||
<where>
|
||||
del_flag = '0'
|
||||
and order_status in
|
||||
<foreach collection="effectiveStatuses" item="status" open="(" separator="," close=")">
|
||||
#{status}
|
||||
</foreach>
|
||||
<if test="report != null and report.repairNo != null and report.repairNo != ''">
|
||||
and repair_no like concat(#{report.repairNo}, '%')
|
||||
</if>
|
||||
<if test="report != null and report.assetCode != null and report.assetCode != ''">
|
||||
and asset_code like concat(#{report.assetCode}, '%')
|
||||
</if>
|
||||
<if test="report != null and report.categoryId != null">
|
||||
and category_id = #{report.categoryId}
|
||||
</if>
|
||||
<if test="report != null and report.reportUserName != null and report.reportUserName != ''">
|
||||
and report_user_name like concat('%', #{report.reportUserName}, '%')
|
||||
</if>
|
||||
<if test="report != null and report.params.beginReportTime != null and report.params.beginReportTime != ''">
|
||||
and report_time >= #{report.params.beginReportTime}
|
||||
</if>
|
||||
<if test="report != null and report.params.endReportTime != null and report.params.endReportTime != ''">
|
||||
and report_time < date_add(#{report.params.endReportTime}, interval 1 day)
|
||||
</if>
|
||||
<if test="report != null and report.orderStatus != null and report.orderStatus != ''">
|
||||
and order_status = #{report.orderStatus}
|
||||
</if>
|
||||
<if test="report != null and report.repairerType != null and report.repairerType != ''">
|
||||
and repairer_type = #{report.repairerType}
|
||||
</if>
|
||||
<if test="report != null and report.repairUserName != null and report.repairUserName != ''">
|
||||
and repair_user_name like concat('%', #{report.repairUserName}, '%')
|
||||
</if>
|
||||
<if test="report != null and report.repairOrgName != null and report.repairOrgName != ''">
|
||||
and repair_org_name like concat('%', #{report.repairOrgName}, '%')
|
||||
</if>
|
||||
<if test='report != null and report.params.overdueFlag != null and report.params.overdueFlag == "Y"'>
|
||||
and expected_finish_time is not null
|
||||
and expected_finish_time < now()
|
||||
and order_status != 'REPAIR_DONE'
|
||||
</if>
|
||||
<if test='report != null and report.params.overdueFlag != null and report.params.overdueFlag == "N"'>
|
||||
and (
|
||||
expected_finish_time is null
|
||||
or expected_finish_time >= now()
|
||||
or order_status = 'REPAIR_DONE'
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<select id="selectRepairDetailReportList" resultMap="AmsRepairDetailReportResult">
|
||||
select
|
||||
<include refid="repairDetailReportColumns"/>
|
||||
from ams_repair_order
|
||||
<include refid="repairDetailReportWhere"/>
|
||||
order by report_time desc, repair_id desc
|
||||
</select>
|
||||
</mapper>
|
||||
@ -0,0 +1,181 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||
<head>
|
||||
<th:block th:include="include :: header('报修维修明细报表')" />
|
||||
<th:block th:include="include :: datetimepicker-css" />
|
||||
<th:block th:include="include :: select2-css" />
|
||||
</head>
|
||||
<body class="gray-bg">
|
||||
<div class="container-div">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 search-collapse">
|
||||
<form id="formId">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
<label>报修单号:</label>
|
||||
<input type="text" name="repairNo"/>
|
||||
</li>
|
||||
<li class="select-time">
|
||||
<label>报修日期:</label>
|
||||
<input type="text" class="time-input" id="startTime" placeholder="开始时间"
|
||||
name="params[beginReportTime]"/>
|
||||
<span>-</span>
|
||||
<input type="text" class="time-input" id="endTime" placeholder="结束时间"
|
||||
name="params[endReportTime]"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>维修状态:</label>
|
||||
<select name="orderStatus" class="select2-control" style="width: 170px">
|
||||
<option value="">所有</option>
|
||||
<option th:each="dict : ${@dict.getType('ams_repair_status')}"
|
||||
th:if="${dict.dictValue == 'WAIT_REPAIR' or dict.dictValue == 'REPAIRING' or dict.dictValue == 'REPAIR_DONE'}"
|
||||
th:value="${dict.dictValue}"
|
||||
th:text="${dict.dictLabel}"></option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<label>是否超期:</label>
|
||||
<select name="params[overdueFlag]" class="select2-control" style="width: 120px">
|
||||
<option value="">所有</option>
|
||||
<option value="Y">已超期</option>
|
||||
<option value="N">未超期</option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<label>维修方:</label>
|
||||
<select name="repairerType" class="select2-control" style="width: 150px">
|
||||
<option value="">所有</option>
|
||||
<option th:each="dict : ${@dict.getType('ams_repairer_type')}"
|
||||
th:value="${dict.dictValue}"
|
||||
th:text="${dict.dictLabel}"></option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<label>维修人:</label>
|
||||
<input type="text" name="repairUserName"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>维修单位:</label>
|
||||
<input type="text" name="repairOrgName"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>资产编码:</label>
|
||||
<input type="text" name="assetCode"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>资产类别:</label>
|
||||
<select name="categoryId" class="select2-control" style="width: 170px">
|
||||
<option value="">所有</option>
|
||||
<option th:each="category : ${categoryList}"
|
||||
th:value="${category.categoryId}"
|
||||
th:text="${category.categoryName}"></option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()">
|
||||
<i class="fa fa-search"></i> 搜索
|
||||
</a>
|
||||
<a class="btn btn-warning btn-rounded btn-sm" onclick="resetReportSearch()">
|
||||
<i class="fa fa-refresh"></i> 重置
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="btn-group-sm" id="toolbar" role="group">
|
||||
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="asset:report:repair:export">
|
||||
<i class="fa fa-download"></i> 导出
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<th:block th:include="include :: datetimepicker-js" />
|
||||
<th:block th:include="include :: select2-js" />
|
||||
<script th:inline="javascript">
|
||||
var repairerTypeDatas = [[${@dict.getType('ams_repairer_type')}]];
|
||||
var orderStatusDatas = [[${@dict.getType('ams_repair_status')}]];
|
||||
var prefix = ctx + "asset/report/repair";
|
||||
|
||||
$(function() {
|
||||
$(".select2-control").select2({
|
||||
placeholder: "请选择",
|
||||
allowClear: true
|
||||
});
|
||||
var options = {
|
||||
url: prefix + "/list",
|
||||
exportUrl: prefix + "/export",
|
||||
modalName: "报修维修明细报表",
|
||||
columns: [{
|
||||
field: 'repairNo',
|
||||
title: '报修单号'
|
||||
},
|
||||
{
|
||||
field: 'assetCode',
|
||||
title: '资产编码'
|
||||
},
|
||||
{
|
||||
field: 'assetName',
|
||||
title: '资产名称'
|
||||
},
|
||||
{
|
||||
field: 'categoryName',
|
||||
title: '资产类别'
|
||||
},
|
||||
{
|
||||
field: 'reportUserName',
|
||||
title: '报修人'
|
||||
},
|
||||
{
|
||||
field: 'reportTime',
|
||||
title: '报修时间'
|
||||
},
|
||||
{
|
||||
field: 'repairerType',
|
||||
title: '维修方',
|
||||
formatter: function(value) {
|
||||
return $.table.selectDictLabel(repairerTypeDatas, value) || "-";
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'repairUserName',
|
||||
title: '维修人'
|
||||
},
|
||||
{
|
||||
field: 'repairOrgName',
|
||||
title: '维修单位'
|
||||
},
|
||||
{
|
||||
field: 'repairFinishTime',
|
||||
title: '维修完成时间'
|
||||
},
|
||||
{
|
||||
field: 'repairCost',
|
||||
title: '维修费用',
|
||||
align: 'right'
|
||||
},
|
||||
{
|
||||
field: 'orderStatus',
|
||||
title: '状态',
|
||||
formatter: function(value) {
|
||||
return $.table.selectDictLabel(orderStatusDatas, value);
|
||||
}
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
|
||||
function resetReportSearch() {
|
||||
$.form.reset();
|
||||
$(".select2-control").val("").trigger("change");
|
||||
$.table.search();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,84 @@
|
||||
package com.ruoyi.asset.service.impl;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyList;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import com.ruoyi.asset.constant.RepairOrderStatus;
|
||||
import com.ruoyi.asset.domain.AmsRepairDetailReport;
|
||||
import com.ruoyi.asset.mapper.AmsRepairDetailReportMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class AmsRepairDetailReportServiceImplTest
|
||||
{
|
||||
@Mock
|
||||
private AmsRepairDetailReportMapper amsRepairDetailReportMapper;
|
||||
|
||||
@InjectMocks
|
||||
private AmsRepairDetailReportServiceImpl service;
|
||||
|
||||
/** 报表只展示已受理后的维修事实,避免草稿、待确认、驳回单据污染统计口径。 */
|
||||
@Test
|
||||
void selectRepairDetailReportListShouldAlwaysUseEffectiveStatuses()
|
||||
{
|
||||
AmsRepairDetailReport query = new AmsRepairDetailReport();
|
||||
query.setRepairerType("INTERNAL");
|
||||
query.setOrderStatus(RepairOrderStatus.REPAIRING);
|
||||
when(amsRepairDetailReportMapper.selectRepairDetailReportList(query, List.of(
|
||||
RepairOrderStatus.WAIT_REPAIR, RepairOrderStatus.REPAIRING, RepairOrderStatus.REPAIR_DONE)))
|
||||
.thenReturn(List.of());
|
||||
|
||||
service.selectRepairDetailReportList(query);
|
||||
|
||||
ArgumentCaptor<AmsRepairDetailReport> reportCaptor = ArgumentCaptor.forClass(AmsRepairDetailReport.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
ArgumentCaptor<List<String>> statusCaptor = ArgumentCaptor.forClass(List.class);
|
||||
verify(amsRepairDetailReportMapper).selectRepairDetailReportList(reportCaptor.capture(),
|
||||
statusCaptor.capture());
|
||||
assertEquals("INTERNAL", reportCaptor.getValue().getRepairerType());
|
||||
assertEquals(RepairOrderStatus.REPAIRING, reportCaptor.getValue().getOrderStatus());
|
||||
assertEquals(List.of(RepairOrderStatus.WAIT_REPAIR, RepairOrderStatus.REPAIRING,
|
||||
RepairOrderStatus.REPAIR_DONE), statusCaptor.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void selectRepairDetailReportListShouldHandleNullQuery()
|
||||
{
|
||||
when(amsRepairDetailReportMapper.selectRepairDetailReportList(any(AmsRepairDetailReport.class), anyList()))
|
||||
.thenReturn(List.of());
|
||||
|
||||
service.selectRepairDetailReportList(null);
|
||||
|
||||
verify(amsRepairDetailReportMapper).selectRepairDetailReportList(any(AmsRepairDetailReport.class), anyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
void selectRepairDetailReportListShouldReturnMapperRows()
|
||||
{
|
||||
AmsRepairDetailReport row = new AmsRepairDetailReport();
|
||||
row.setRepairNo("BX202606170003");
|
||||
row.setAssetCode("TEST-ASSET-003");
|
||||
row.setRepairCost(new BigDecimal("234.00"));
|
||||
row.setOrderStatus(RepairOrderStatus.REPAIR_DONE);
|
||||
when(amsRepairDetailReportMapper.selectRepairDetailReportList(any(AmsRepairDetailReport.class), anyList()))
|
||||
.thenReturn(List.of(row));
|
||||
|
||||
List<AmsRepairDetailReport> result = service.selectRepairDetailReportList(new AmsRepairDetailReport());
|
||||
|
||||
assertEquals(1, result.size());
|
||||
assertEquals("BX202606170003", result.get(0).getRepairNo());
|
||||
assertEquals("TEST-ASSET-003", result.get(0).getAssetCode());
|
||||
assertEquals(new BigDecimal("234.00"), result.get(0).getRepairCost());
|
||||
assertEquals(RepairOrderStatus.REPAIR_DONE, result.get(0).getOrderStatus());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue