万能试验机

This commit is contained in:
guo 2024-01-26 09:36:58 +08:00
parent 3dbb2476ec
commit 822122c754
12 changed files with 279 additions and 51 deletions

View File

@ -182,4 +182,12 @@ public class UniversalTestDevController {
return mv;
}
@ApiOperation(value = "万能机设备统计", notes = "万能机设备统计", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
})
@PostMapping(value = "/countUniversalTestDev")
public Result<List<UniversalTestDev>> countUniversalTestDev(@ApiIgnore @RequestBody HashMap<String, Object> paramMap) {
return Result.success(universalTestDevService.countUniversalTestDev(paramMap));
}
}

View File

@ -1,39 +1,37 @@
package com.zhgd.xmgl.modules.universaltest.controller;
import com.zhgd.xmgl.modules.universaltest.service.IUniversalTestManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParams;
import java.util.HashMap;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.jeecg.common.system.query.QueryGenerator;
import com.zhgd.jeecg.common.util.oConvertUtils;
import org.apache.commons.collections.MapUtils;
import com.zhgd.xmgl.base.entity.vo.SectorVo;
import com.zhgd.xmgl.base.entity.vo.TrendOneVo;
import com.zhgd.xmgl.base.entity.vo.TrendVo;
import com.zhgd.xmgl.modules.antipressurefold.entity.vo.CountAntiPressureFoldManageVo;
import com.zhgd.xmgl.modules.universaltest.entity.UniversalTestManage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zhgd.xmgl.modules.universaltest.service.IUniversalTestManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.List;
/**
@ -100,7 +98,7 @@ public class UniversalTestManageController {
@ApiOperation(value = "编辑万能试验机管理信息", notes = "编辑万能试验机管理信息", httpMethod = "POST")
@PostMapping(value = "/edit")
public Result<UniversalTestManage> edit(@RequestBody UniversalTestManage universalTestManage) {
universalTestManageService.updateById(universalTestManage);
universalTestManageService.edit(universalTestManage);
return Result.ok();
}
@ -182,4 +180,33 @@ public class UniversalTestManageController {
return mv;
}
@ApiOperation(value = "统计万能试验机管理(实时监测)", notes = "统计万能试验机管理(实时监测)", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
})
@PostMapping(value = "/countUniversalTestManage")
public Result<CountAntiPressureFoldManageVo> countUniversalTestManage(@ApiIgnore @RequestBody HashMap<String, Object> paramMap) {
return Result.success(universalTestManageService.countUniversalTestManage(paramMap));
}
@ApiOperation(value = "统计试验类型(各类型试验次数)", notes = "统计试验类型(各类型试验次数)", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "devSn", value = "设备sn", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "type", value = "1今日2、7日3、30日", paramType = "body", required = true, dataType = "Integer"),
})
@PostMapping(value = "/countTestType")
public Result<SectorVo> countTestType(@ApiIgnore @RequestBody HashMap<String, Object> paramMap) {
return Result.success(universalTestManageService.countTestType(paramMap));
}
@ApiOperation(value = "统计试验次数(累计试验次数)", notes = "统计试验次数(累计试验次数)", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "type", value = "1今日2、7日3、30日", paramType = "body", required = true, dataType = "Integer"),
})
@PostMapping(value = "/countTestNum")
public Result<List<TrendVo>> countTestNum(@ApiIgnore @RequestBody HashMap<String, Object> paramMap) {
return Result.success(universalTestManageService.countTestNum(paramMap));
}
}

View File

@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@ -91,14 +92,18 @@ public class UniversalTestDev implements Serializable {
@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private java.util.Date createTime;
/**
* 更新时间
*/
@Excel(name = "更新时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新时间")
private java.util.Date updateTime;
@ApiModelProperty(value = "创建时间")
private java.util.Date createTime;
/**
* 更新时间
*/
@Excel(name = "更新时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新时间")
private java.util.Date updateTime;
@TableField(exist = false)
@ApiModelProperty(value = "试验总次数")
private Integer testTotalNum;
}

View File

@ -121,21 +121,23 @@ public class UniversalTestManage implements Serializable {
*/
@Excel(name = "更新时间 yyyy-MM-dd HH:mm:ss", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新时间 yyyy-MM-dd HH:mm:ss")
private java.util.Date updateDate;
/**
* 项目sn
*/
@Excel(name = "项目sn", width = 15)
@ApiModelProperty(value = "项目sn")
private java.lang.String projectSn;
@ApiModelProperty(value = "上传附件")
private java.lang.String uploadAttachment;
@TableField(exist = false)
@ApiModelProperty(value = "设备名称")
private java.lang.String deviceName;
@TableField(exist = false)
@ApiModelProperty(value = "所属试验室")
private java.lang.String affiliatedLaboratory;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新时间 yyyy-MM-dd HH:mm:ss")
private java.util.Date updateDate;
/**
* 项目sn
*/
@Excel(name = "项目sn", width = 15)
@ApiModelProperty(value = "项目sn")
private java.lang.String projectSn;
@ApiModelProperty(value = "上传附件")
private java.lang.String uploadAttachment;
@ApiModelProperty(value = "报告上传次数")
private java.lang.Integer reportUploadNum;
@TableField(exist = false)
@ApiModelProperty(value = "设备名称")
private java.lang.String deviceName;
@TableField(exist = false)
@ApiModelProperty(value = "所属试验室")
private java.lang.String affiliatedLaboratory;
}

View File

@ -4,6 +4,9 @@ import com.zhgd.xmgl.modules.universaltest.entity.UniversalTestDev;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.HashMap;
import java.util.List;
/**
* @Description: 万能试验机-设备
* @author pds
@ -13,4 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@Mapper
public interface UniversalTestDevMapper extends BaseMapper<UniversalTestDev> {
List<UniversalTestDev> countUniversalTestDev(HashMap<String, Object> paramMap);
}

View File

@ -4,11 +4,15 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhgd.xmgl.base.entity.vo.SectorOneVo;
import com.zhgd.xmgl.base.entity.vo.TrendOneVo;
import com.zhgd.xmgl.modules.antipressurefold.entity.vo.CountAntiPressureFoldManageVo;
import com.zhgd.xmgl.modules.universaltest.entity.UniversalTestManage;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.List;
/**
@ -23,4 +27,10 @@ public interface UniversalTestManageMapper extends BaseMapper<UniversalTestManag
List<UniversalTestManage> queryList(@Param(Constants.WRAPPER) QueryWrapper<UniversalTestManage> queryWrapper);
IPage<UniversalTestManage> queryList(Page<UniversalTestManage> page, @Param(Constants.WRAPPER) QueryWrapper<UniversalTestManage> queryWrapper);
CountAntiPressureFoldManageVo countUniversalTestManage(HashMap<String, Object> paramMap);
List<SectorOneVo> countTestType(HashMap<String, Object> paramMap);
List<TrendOneVo> countTestNum(HashMap<String, Object> paramMap);
}

View File

@ -1,4 +1,14 @@
<?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.zhgd.xmgl.modules.universaltest.mapper.UniversalTestDevMapper">
<select id="countUniversalTestDev" resultType="com.zhgd.xmgl.modules.universaltest.entity.UniversalTestDev">
select utd.device_name, count(utm.id) testTotalNum
from universal_test_dev utd
left join universal_test_manage utm on utd.dev_sn = utm.dev_sn and utd.project_sn = utm.project_sn
where 1=1
<if test="projectSn != null and projectSn != ''">
and utd.project_sn = #{projectSn}
</if>
group by utd.dev_sn
</select>
</mapper>

View File

@ -7,4 +7,92 @@
join universal_test_dev utd on utd.dev_sn=utm.dev_sn
${ew.customSqlSegment}
</select>
<select id="countUniversalTestManage"
resultType="com.zhgd.xmgl.modules.antipressurefold.entity.vo.CountAntiPressureFoldManageVo">
select count(*) testTotalNum,
ifnull(sum(if(test_time>current_date,1,0)),0) testTodayNum
from universal_test_manage
where project_sn=#{projectSn}
<if test="devSn != null and devSn != ''">
and dev_sn = #{devSn}
</if>
</select>
<select id="countTestType" resultType="com.zhgd.xmgl.base.entity.vo.SectorOneVo">
select test_type enumType,count(*) count
from universal_test_manage
where project_sn=#{projectSn}
<if test="devSn != null and devSn != ''">
and dev_sn = #{devSn}
</if>
<if test="type == '1'.toString()">
and test_time > current_date
</if>
<if test="type == '2'.toString()">
and test_time > date_sub(test_time,interval 6 day)
</if>
<if test="type == '3'.toString()">
and test_time > date_sub(test_time,interval 29 day)
</if>
group by test_type
</select>
<select id="countTestNum" resultType="com.zhgd.xmgl.base.entity.vo.TrendOneVo">
select
<if test="type == '1'.toString()">
date_format(test_time,'%Y-%m-%d %H:00') x,
</if>
<if test="type == '2'.toString()">
date_format(test_time,'%Y-%m-%d') x,
</if>
<if test="type == '3'.toString()">
date_format(test_time,'%Y-%m-%d') x,
</if>
count(*) y,
1 sn
from universal_test_manage
where project_sn=#{projectSn}
<if test="devSn != null and devSn != ''">
and dev_sn = #{devSn}
</if>
<if test="type == '1'.toString()">
and test_time > current_date
</if>
<if test="type == '2'.toString()">
and test_time > date_sub(test_time,interval 6 day)
</if>
<if test="type == '3'.toString()">
and test_time > date_sub(test_time,interval 29 day)
</if>
group by x
union all
select
<if test="type == '1'.toString()">
date_format(test_time,'%Y-%m-%d %H:00') x,
</if>
<if test="type == '2'.toString()">
date_format(test_time,'%Y-%m-%d') x,
</if>
<if test="type == '3'.toString()">
date_format(test_time,'%Y-%m-%d') x,
</if>
ifnull(sum(report_upload_num),0) y,
2 sn
from universal_test_manage
where project_sn=#{projectSn}
<if test="devSn != null and devSn != ''">
and dev_sn = #{devSn}
</if>
<if test="type == '1'.toString()">
and test_time > current_date
</if>
<if test="type == '2'.toString()">
and test_time > date_sub(test_time,interval 6 day)
</if>
<if test="type == '3'.toString()">
and test_time > date_sub(test_time,interval 29 day)
</if>
group by x
</select>
</mapper>

View File

@ -18,4 +18,6 @@ public interface IUniversalTestDevService extends IService<UniversalTestDev> {
IPage<UniversalTestDev> queryPageList(HashMap<String, Object> paramMap);
List<UniversalTestDev> queryList(HashMap<String, Object> paramMap);
List<UniversalTestDev> countUniversalTestDev(HashMap<String, Object> paramMap);
}

View File

@ -1,5 +1,8 @@
package com.zhgd.xmgl.modules.universaltest.service;
import com.zhgd.xmgl.base.entity.vo.SectorVo;
import com.zhgd.xmgl.base.entity.vo.TrendVo;
import com.zhgd.xmgl.modules.antipressurefold.entity.vo.CountAntiPressureFoldManageVo;
import com.zhgd.xmgl.modules.universaltest.entity.UniversalTestManage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -18,4 +21,12 @@ public interface IUniversalTestManageService extends IService<UniversalTestManag
IPage<UniversalTestManage> queryPageList(HashMap<String, Object> paramMap);
List<UniversalTestManage> queryList(HashMap<String, Object> paramMap);
CountAntiPressureFoldManageVo countUniversalTestManage(HashMap<String, Object> paramMap);
SectorVo countTestType(HashMap<String, Object> paramMap);
void edit(UniversalTestManage universalTestManage);
List<TrendVo> countTestNum(HashMap<String, Object> paramMap);
}

View File

@ -39,6 +39,11 @@ public class UniversalTestDevServiceImpl extends ServiceImpl<UniversalTestDevMap
return dealList(this.list(queryWrapper));
}
@Override
public List<UniversalTestDev> countUniversalTestDev(HashMap<String, Object> paramMap) {
return baseMapper.countUniversalTestDev(paramMap);
}
private QueryWrapper<UniversalTestDev> getQueryWrapper(HashMap<String, Object> paramMap) {
QueryWrapper<UniversalTestDev> queryWrapper = QueryGenerator.initPageQueryWrapper(UniversalTestDev.class, paramMap);
queryWrapper.orderByDesc(RefUtil.fieldNameUlc(UniversalTestDev::getId));

View File

@ -4,16 +4,26 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhgd.jeecg.common.execption.OpenAlertException;
import com.zhgd.jeecg.common.system.query.QueryGenerator;
import com.zhgd.xmgl.base.entity.vo.SectorVo;
import com.zhgd.xmgl.base.entity.vo.TrendOneVo;
import com.zhgd.xmgl.base.entity.vo.TrendVo;
import com.zhgd.xmgl.enums.ParamEnum;
import com.zhgd.xmgl.modules.antipressurefold.entity.vo.CountAntiPressureFoldManageVo;
import com.zhgd.xmgl.modules.universaltest.entity.UniversalTestManage;
import com.zhgd.xmgl.modules.universaltest.mapper.UniversalTestManageMapper;
import com.zhgd.xmgl.modules.universaltest.service.IUniversalTestManageService;
import com.zhgd.xmgl.util.DateUtils;
import com.zhgd.xmgl.util.PageUtil;
import com.zhgd.xmgl.util.RefUtil;
import org.apache.commons.collections.MapUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
/**
* @Description: 万能试验机管理
@ -38,6 +48,52 @@ public class UniversalTestManageServiceImpl extends ServiceImpl<UniversalTestMan
return dealList(baseMapper.queryList(queryWrapper));
}
@Override
public CountAntiPressureFoldManageVo countUniversalTestManage(HashMap<String, Object> paramMap) {
return baseMapper.countUniversalTestManage(paramMap);
}
@Override
public SectorVo countTestType(HashMap<String, Object> paramMap) {
return SectorVo.getSectorVoByEnum(baseMapper.countTestType(paramMap), ParamEnum.UniversalTestManageTestTypeEnum.values());
}
@Override
public void edit(UniversalTestManage universalTestManage) {
UniversalTestManage manage = baseMapper.selectById(universalTestManage.getId());
if (manage == null) {
throw new OpenAlertException("实体类不存在");
}
if (!Objects.equals(manage.getUploadAttachment(), universalTestManage.getUploadAttachment())) {
universalTestManage.setReportUploadNum(manage.getReportUploadNum() + 1);
}
baseMapper.updateById(universalTestManage);
}
@Override
public List<TrendVo> countTestNum(HashMap<String, Object> paramMap) {
Integer type = MapUtils.getInteger(paramMap, "type");
String format = null;
List<String> dateTimeStrList = null;
if (Objects.equals(type, 1)) {
format = "HH:00";
dateTimeStrList = DateUtils.getDateTimeStrList(100, "yyyy-MM-dd HH:00");
} else if (Objects.equals(type, 2)) {
format = "yyyy-MM-dd";
dateTimeStrList = DateUtils.getDateTimeStrList(60, "yyyy-MM-dd");
} else if (Objects.equals(type, 3)) {
format = "yyyy-MM-dd";
dateTimeStrList = DateUtils.getDateTimeStrList(80, "yyyy-MM-dd");
} else {
return null;
}
List<TrendOneVo> list = baseMapper.countTestNum(paramMap);
List<TrendVo> sns = new ArrayList<>();
sns.add(new TrendVo("试验次数", "1"));
sns.add(new TrendVo("报告上传次数", "2"));
return TrendVo.getTrendVos(sns, list, dateTimeStrList, format);
}
private QueryWrapper<UniversalTestManage> getQueryWrapper(HashMap<String, Object> paramMap) {
String alias = "utm.";
QueryWrapper<UniversalTestManage> queryWrapper = QueryGenerator.initPageQueryWrapper(UniversalTestManage.class, paramMap, alias);