统计故障的分组数量
This commit is contained in:
parent
5a83a183dd
commit
ce9b6f4ce4
@ -0,0 +1,113 @@
|
||||
package com.fastbee.data.controller.aaScreenAgricultural;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.fastbee.common.annotation.Log;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import com.fastbee.breakdown.domain.DeviceBreakdown;
|
||||
import com.fastbee.breakdown.service.IDeviceBreakdownService;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
||||
import com.fastbee.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 故障Controller
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/breakdown")
|
||||
@Api(tags = "故障")
|
||||
public class DeviceBreakdownController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IDeviceBreakdownService deviceBreakdownService;
|
||||
|
||||
/**
|
||||
* 查询故障列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询故障列表")
|
||||
public TableDataInfo list(DeviceBreakdown deviceBreakdown)
|
||||
{
|
||||
startPage();
|
||||
List<DeviceBreakdown> list = deviceBreakdownService.selectDeviceBreakdownList(deviceBreakdown);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出故障列表
|
||||
*/
|
||||
@ApiOperation("导出故障列表")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, DeviceBreakdown deviceBreakdown)
|
||||
{
|
||||
List<DeviceBreakdown> list = deviceBreakdownService.selectDeviceBreakdownList(deviceBreakdown);
|
||||
ExcelUtil<DeviceBreakdown> util = new ExcelUtil<DeviceBreakdown>(DeviceBreakdown.class);
|
||||
util.exportExcel(response, list, "故障数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取故障详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiOperation("获取故障详细信息")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(deviceBreakdownService.selectDeviceBreakdownById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增故障
|
||||
*/
|
||||
@PostMapping
|
||||
@ApiOperation("新增故障")
|
||||
public AjaxResult add(@RequestBody DeviceBreakdown deviceBreakdown)
|
||||
{
|
||||
return toAjax(deviceBreakdownService.insertDeviceBreakdown(deviceBreakdown));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改故障
|
||||
*/
|
||||
@PutMapping
|
||||
@ApiOperation("修改故障")
|
||||
public AjaxResult edit(@RequestBody DeviceBreakdown deviceBreakdown)
|
||||
{
|
||||
return toAjax(deviceBreakdownService.updateDeviceBreakdown(deviceBreakdown));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除故障
|
||||
*/
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除故障")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(deviceBreakdownService.deleteDeviceBreakdownByIds(ids));
|
||||
}
|
||||
/*
|
||||
*
|
||||
*/
|
||||
@GetMapping("/statistics")
|
||||
@ApiOperation("查询故障列表")
|
||||
public AjaxResult getFaultStatistics(String TypeValue, String CreateTimeValue)
|
||||
{
|
||||
return success(deviceBreakdownService.getFaultStatistics(TypeValue, CreateTimeValue));
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.fastbee.breakdown.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.fastbee.common.annotation.Excel;
|
||||
import com.fastbee.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 故障对象 iot_device_breakdown
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
@ApiModel(value = "DeviceBreakdown",description = "故障 iot_device_breakdown")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("iot_device_breakdown")
|
||||
public class DeviceBreakdown extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
private Long id;
|
||||
|
||||
/** 分类 */
|
||||
@Excel(name = "分类")
|
||||
@ApiModelProperty("分类")
|
||||
private String type;
|
||||
|
||||
/** 故障名 */
|
||||
@Excel(name = "故障名")
|
||||
@ApiModelProperty("故障名")
|
||||
private String faultName;
|
||||
|
||||
/** 删除标志(0代表存在,2代表删除) */
|
||||
private Integer delFlag;
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.fastbee.breakdown.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class IotDeviceBreakdown {
|
||||
private Long counts;
|
||||
|
||||
private String fault_name;
|
||||
|
||||
private String type;
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.fastbee.breakdown.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fastbee.breakdown.domain.DeviceBreakdown;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 故障Mapper接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceBreakdownMapper extends BaseMapper<DeviceBreakdown>
|
||||
{
|
||||
/**
|
||||
* 查询故障
|
||||
*
|
||||
* @param id 故障主键
|
||||
* @return 故障
|
||||
*/
|
||||
public DeviceBreakdown selectDeviceBreakdownById(Long id);
|
||||
|
||||
/**
|
||||
* 查询故障列表
|
||||
*
|
||||
* @param deviceBreakdown 故障
|
||||
* @return 故障集合
|
||||
*/
|
||||
public List<DeviceBreakdown> selectDeviceBreakdownList(DeviceBreakdown deviceBreakdown);
|
||||
|
||||
/**
|
||||
* 新增故障
|
||||
*
|
||||
* @param deviceBreakdown 故障
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDeviceBreakdown(DeviceBreakdown deviceBreakdown);
|
||||
|
||||
/**
|
||||
* 修改故障
|
||||
*
|
||||
* @param deviceBreakdown 故障
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDeviceBreakdown(DeviceBreakdown deviceBreakdown);
|
||||
|
||||
/**
|
||||
* 删除故障
|
||||
*
|
||||
* @param id 故障主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDeviceBreakdownById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除故障
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDeviceBreakdownByIds(Long[] ids);
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package com.fastbee.breakdown.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.fastbee.breakdown.domain.dto.IotDeviceBreakdown;
|
||||
import com.fastbee.breakdown.domain.DeviceBreakdown;
|
||||
|
||||
/**
|
||||
* 故障Service接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
public interface IDeviceBreakdownService
|
||||
{
|
||||
/**
|
||||
* 查询故障
|
||||
*
|
||||
* @param id 故障主键
|
||||
* @return 故障
|
||||
*/
|
||||
public DeviceBreakdown selectDeviceBreakdownById(Long id);
|
||||
|
||||
/**
|
||||
* 查询故障列表
|
||||
*
|
||||
* @param deviceBreakdown 故障
|
||||
* @return 故障集合
|
||||
*/
|
||||
public List<DeviceBreakdown> selectDeviceBreakdownList(DeviceBreakdown deviceBreakdown);
|
||||
|
||||
/**
|
||||
* 新增故障
|
||||
*
|
||||
* @param deviceBreakdown 故障
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDeviceBreakdown(DeviceBreakdown deviceBreakdown);
|
||||
|
||||
/**
|
||||
* 修改故障
|
||||
*
|
||||
* @param deviceBreakdown 故障
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDeviceBreakdown(DeviceBreakdown deviceBreakdown);
|
||||
|
||||
/**
|
||||
* 批量删除故障
|
||||
*
|
||||
* @param ids 需要删除的故障主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDeviceBreakdownByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除故障信息
|
||||
*
|
||||
* @param id 故障主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDeviceBreakdownById(Long id);
|
||||
|
||||
/**
|
||||
* 统计故障的分组数量
|
||||
* @param TypeValue
|
||||
* @param CreateTimeValue
|
||||
* @return
|
||||
*/
|
||||
public List<IotDeviceBreakdown> getFaultStatistics(String TypeValue,String CreateTimeValue);
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
package com.fastbee.breakdown.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.fastbee.breakdown.domain.dto.IotDeviceBreakdown;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import lombok.var;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fastbee.breakdown.mapper.DeviceBreakdownMapper;
|
||||
import com.fastbee.breakdown.domain.DeviceBreakdown;
|
||||
import com.fastbee.breakdown.service.IDeviceBreakdownService;
|
||||
|
||||
/**
|
||||
* 故障Service业务层处理
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
@Service
|
||||
public class DeviceBreakdownServiceImpl implements IDeviceBreakdownService
|
||||
{
|
||||
@Autowired
|
||||
private DeviceBreakdownMapper deviceBreakdownMapper;
|
||||
|
||||
/**
|
||||
* 查询故障
|
||||
*
|
||||
* @param id 故障主键
|
||||
* @return 故障
|
||||
*/
|
||||
@Override
|
||||
public DeviceBreakdown selectDeviceBreakdownById(Long id)
|
||||
{
|
||||
return deviceBreakdownMapper.selectDeviceBreakdownById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询故障列表
|
||||
*
|
||||
* @param deviceBreakdown 故障
|
||||
* @return 故障
|
||||
*/
|
||||
@Override
|
||||
public List<DeviceBreakdown> selectDeviceBreakdownList(DeviceBreakdown deviceBreakdown)
|
||||
{
|
||||
return deviceBreakdownMapper.selectDeviceBreakdownList(deviceBreakdown);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增故障
|
||||
*
|
||||
* @param deviceBreakdown 故障
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertDeviceBreakdown(DeviceBreakdown deviceBreakdown)
|
||||
{
|
||||
deviceBreakdown.setCreateTime(DateUtils.getNowDate());
|
||||
return deviceBreakdownMapper.insertDeviceBreakdown(deviceBreakdown);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改故障
|
||||
*
|
||||
* @param deviceBreakdown 故障
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDeviceBreakdown(DeviceBreakdown deviceBreakdown)
|
||||
{
|
||||
deviceBreakdown.setUpdateTime(DateUtils.getNowDate());
|
||||
return deviceBreakdownMapper.updateDeviceBreakdown(deviceBreakdown);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除故障
|
||||
*
|
||||
* @param ids 需要删除的故障主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDeviceBreakdownByIds(Long[] ids)
|
||||
{
|
||||
return deviceBreakdownMapper.deleteDeviceBreakdownByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除故障信息
|
||||
*
|
||||
* @param id 故障主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDeviceBreakdownById(Long id)
|
||||
{
|
||||
return deviceBreakdownMapper.deleteDeviceBreakdownById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计故障的分组数量
|
||||
* @param TypeValue
|
||||
* @param CreateTimeValue
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<IotDeviceBreakdown> getFaultStatistics(String TypeValue, String CreateTimeValue){
|
||||
QueryWrapper<DeviceBreakdown> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("Type", TypeValue)
|
||||
.ge("create_time",CreateTimeValue)
|
||||
.select("count(*) as id", "fault_name", "create_time","Type")
|
||||
.groupBy("fault_name");
|
||||
List<IotDeviceBreakdown> breakdown = new ArrayList<>();
|
||||
QueryWrapper<DeviceBreakdown> query = new QueryWrapper<>();
|
||||
query.eq("Type",TypeValue);
|
||||
QueryWrapper<DeviceBreakdown> queryTime = new QueryWrapper<>();
|
||||
queryTime.ge("create_time",CreateTimeValue);
|
||||
if ((deviceBreakdownMapper.selectCount(query) <=0)||(deviceBreakdownMapper.selectCount(queryTime)<=0)) {
|
||||
return breakdown;
|
||||
}
|
||||
System.err.println(deviceBreakdownMapper.selectList(queryWrapper));
|
||||
for (var item : deviceBreakdownMapper.selectList(queryWrapper))
|
||||
{
|
||||
IotDeviceBreakdown breakdownItem = new IotDeviceBreakdown();
|
||||
breakdownItem.setCounts(item.getId());
|
||||
breakdownItem.setFault_name(item.getFaultName());
|
||||
breakdownItem.setType(item.getType());
|
||||
breakdown.add(breakdownItem);
|
||||
}
|
||||
return breakdown;
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
<?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.fastbee.breakdown.mapper.DeviceBreakdownMapper">
|
||||
|
||||
<resultMap type="DeviceBreakdown" id="DeviceBreakdownResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="type" column="Type" />
|
||||
<result property="faultName" column="fault_name" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDeviceBreakdownVo">
|
||||
select id, Type, fault_name, update_by, del_flag, create_time, create_by, update_time from iot_device_breakdown
|
||||
</sql>
|
||||
|
||||
<select id="selectDeviceBreakdownList" parameterType="DeviceBreakdown" resultMap="DeviceBreakdownResult">
|
||||
<include refid="selectDeviceBreakdownVo"/>
|
||||
<where>
|
||||
<if test="type != null and type != ''"> and Type = #{type}</if>
|
||||
<if test="faultName != null and faultName != ''"> and fault_name like concat('%', #{faultName}, '%')</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceBreakdownById" parameterType="Long" resultMap="DeviceBreakdownResult">
|
||||
<include refid="selectDeviceBreakdownVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertDeviceBreakdown" parameterType="DeviceBreakdown" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into iot_device_breakdown
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="type != null">Type,</if>
|
||||
<if test="faultName != null">fault_name,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="faultName != null">#{faultName},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateDeviceBreakdown" parameterType="DeviceBreakdown">
|
||||
update iot_device_breakdown
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="type != null">Type = #{type},</if>
|
||||
<if test="faultName != null">fault_name = #{faultName},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteDeviceBreakdownById" parameterType="Long">
|
||||
delete from iot_device_breakdown where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteDeviceBreakdownByIds" parameterType="String">
|
||||
delete from iot_device_breakdown where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user