试验管理

This commit is contained in:
cwchen 2024-07-20 15:18:16 +08:00
parent 2fdf9144f2
commit bf02fb1295
10 changed files with 641 additions and 1 deletions

View File

@ -0,0 +1,69 @@
package com.bonus.aqgqj.basis.controller;
import com.bonus.aqgqj.annotation.DecryptAndVerify;
import com.bonus.aqgqj.annotation.LogAnnotation;
import com.bonus.aqgqj.basis.entity.dto.ParamsDto;
import com.bonus.aqgqj.basis.entity.vo.ExperimentalDetailVo;
import com.bonus.aqgqj.basis.entity.vo.ExperimentalVo;
import com.bonus.aqgqj.basis.service.ExperimentalService;
import com.bonus.aqgqj.system.vo.EncryptedReq;
import com.bonus.aqgqj.utils.ServerResponse;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @className:ExperimentalController
* @author:cwchen
* @date:2024-07-20-12:07
* @version:1.0
* @description:试验管理-controller
*/
@RestController
@RequestMapping("/experimental/")
@Slf4j
public class ExperimentalController {
@Resource(name = "ExperimentalService")
private ExperimentalService service;
@PostMapping(value = "getList")
@DecryptAndVerify(decryptedClass = ParamsDto.class)//加解密统一管理
@LogAnnotation(operModul = "试验管理", operation = "查询列表", operDesc = "系统级事件", operType = "查询")
// @PreAuthorize("@pms.hasPermission('sys:experimental:query')" )
public ServerResponse getList(EncryptedReq<ParamsDto> data) {
PageHelper.startPage(data.getData().getPage(), data.getData().getLimit());
List<ExperimentalVo> list = service.getList(data.getData());
PageInfo<ExperimentalVo> pageInfo = new PageInfo<>(list);
return ServerResponse.createSuccessPage(pageInfo, data.getData().getPage(), data.getData().getLimit());
}
@PostMapping(value = "getDetailList")
@DecryptAndVerify(decryptedClass = ParamsDto.class)//加解密统一管理
@LogAnnotation(operModul = "试验管理", operation = "查询试验详情列表", operDesc = "系统级事件", operType = "查询")
public ServerResponse getDetailList(EncryptedReq<ParamsDto> data) {
PageHelper.startPage(data.getData().getPage(), data.getData().getLimit());
List<ExperimentalDetailVo> list = service.getDetailList(data.getData());
PageInfo<ExperimentalDetailVo> pageInfo = new PageInfo<>(list);
return ServerResponse.createSuccessPage(pageInfo, data.getData().getPage(), data.getData().getLimit());
}
/**
* 查询试验模板数据基础数据
* @param data
* @return ServerResponse
* @author cwchen
* @date 2024/7/20 14:12
*/
@PostMapping(value = "getTestBasicInfo")
@DecryptAndVerify(decryptedClass = ParamsDto.class)//加解密统一管理
public ServerResponse getTestBasicInfo(EncryptedReq<ParamsDto> data) {
return service.getTestBasicInfo(data.getData());
}
}

View File

@ -0,0 +1,48 @@
package com.bonus.aqgqj.basis.dao;
import com.bonus.aqgqj.basis.entity.dto.ParamsDto;
import com.bonus.aqgqj.basis.entity.vo.ExperimentalDetailVo;
import com.bonus.aqgqj.basis.entity.vo.ExperimentalVo;
import com.bonus.aqgqj.basis.entity.vo.TestVo;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @className:ExperimentalMapper
* @author:cwchen
* @date:2024-07-20-12:10
* @version:1.0
* @description:试验管理-mapper
*/
@Repository(value = "ExperimentalMapper")
public interface ExperimentalMapper {
/**
* 试验列表
*
* @param dto
* @return List<ExperimentalVo>
* @author cwchen
* @date 2024/7/20 12:32
*/
public List<ExperimentalVo> getList(ParamsDto dto);
/**
* 试验详情列表
*
* @param dto
* @return List<ExperimentalDetailVo>
* @author cwchen
* @date 2024/7/20 13:27
*/
List<ExperimentalDetailVo> getDetailList(ParamsDto dto);
/**
* 查询试验模板数据基础数据
* @param dto
* @return TestVo
* @author cwchen
* @date 2024/7/20 14:23
*/
TestVo getTestBasicInfo(ParamsDto dto);
}

View File

@ -21,4 +21,20 @@ public class ParamsDto extends PageEntity {
* 设备类型
*/
private String devTypeCode;
/**
* 收样人
*/
private String sampleUserName;
/**
* 收样时间
*/
private String sampleDate;
/**
* 关键字
*/
private String keyWord;
}

View File

@ -0,0 +1,68 @@
package com.bonus.aqgqj.basis.entity.vo;
import lombok.Data;
import java.util.List;
/**
* @className:ExperimentalVo
* @author:cwchen
* @date:2024-07-20-12:19
* @version:1.0
* @description:试验详情-vo
*/
@Data
public class ExperimentalDetailVo {
/**
* 收样信息表id
*/
private Long sampleId;
/**
* 样品类型
*/
private String devTypeName;
/**
* 样品类型编码
*/
private String devTypeCode;
/**
* 规格型号
*/
private String devModule;
/**
* 样品数量
*/
private Integer sampleQuantity = 0;
/**
* 样品List
*/
private List<Sample> sampleList;
/**
* 驳回原因
*/
private String causeOfRejection;
/**
* 状态
*/
private String status;
/**
* 样品
*/
@Data
public static class Sample {
/**
* 设备编号
*/
private String devCode;
/**
* 试验结果
*/
private String testResult;
}
}

View File

@ -0,0 +1,65 @@
package com.bonus.aqgqj.basis.entity.vo;
import lombok.Data;
/**
* @className:ExperimentalVo
* @author:cwchen
* @date:2024-07-20-12:19
* @version:1.0
* @description:试验管理-vo
*/
@Data
public class ExperimentalVo {
/**
* id
*/
private Long id;
/**
* 送样单位
*/
private String customName;
/**
* 送样时间
*/
private String sampleTime;
/**
* 送样设备
*/
private String sampleDev;
/**
* 送样数量
*/
private Integer customNum;
/**
* 收样人
*/
private String sampleUserName;
/**
* 收样时间
*/
private String sampleDate;
/**
* 派工人
*/
private String dispatchUserName;
;
/**
* 试验班组
*/
private String teamName;
/**
* 审核状态 0 待审核 1审核通过 2审核不通过
*/
private String audtiStatus;
/**
* 流程状态 0.待试验 1.待审阅 2.待审核 3.待审批 4.试验结束 5.待重新审阅
*/
private String processStatus;
/**
* 备注
*/
private String remarks;
}

View File

@ -0,0 +1,162 @@
package com.bonus.aqgqj.basis.entity.vo;
import com.bonus.aqgqj.utils.UserUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.List;
/**
* @className:TestVo
* @author:cwchen
* @date:2024-07-20-14:15
* @version:1.0
* @description:试验-vo
*/
@Data
public class TestVo {
/**
* id
*/
private Long id;
/**
* 试验标准ID
*/
private Long configId;
/**
* 收样日期
*/
private String sampleDate;
/**
* 送检单位ID
*/
private Long submit_unit;
/**
* 送检单位名称
*/
private String customName;
/**
* 试验日期
*/
private String experTime;
/**
* 下次试验日期
*/
private String nextExperTime;
/**
* 设备类型编码
*/
@NotBlank(message = "设备类型编码不能为空", groups = {Query.class})
@Length(max = 32, message = "设备类型字符长度不能超过32", groups = {Query.class})
private String devTypeCode;
/**
* 设备类型名称
*/
@NotBlank(message = "设备类型名称不能为空", groups = {Query.class})
@Length(max = 64, message = "设备类型名称字符长度不能超过64", groups = {Query.class})
private String devTypeName;
/**
* 设备规格型号
*/
@NotBlank(message = "设备规格型号不能为空", groups = {Query.class})
@Length(max = 128, message = "设备规格型号字符长度不能超过128", groups = {Query.class})
private String devModule;
/**
* 实验地点编码
*/
private String experLocalCode;
/**
* 实验地点
*/
@NotBlank(message = "实验地点不能为空", groups = {Query.class})
@Length(max = 128, message = "实验地点字符长度不能超过128", groups = {Query.class})
private String experLocal;
/**
* 删除状态
*/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Integer delFlag = 0;
/**
* 创建人
*/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Long createUser = UserUtil.getLoginUser().getId();
/**
* 创建时间
*/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime = new Date();
/**
* 修改人
*/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Long updateUser = UserUtil.getLoginUser().getId();
/**
* 修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Date updateTime = new Date();
/**
* 试验标准
*/
@NotBlank(message = "试验标准不能为空", groups = {Query.class})
@Length(max = 256, message = "试验标准字符长度不能超过256", groups = {Query.class})
private String experStand;
/**
* 试验结论
*/
@NotBlank(message = "试验结论不能为空", groups = {Query.class})
@Length(max = 256, message = "试验结论字符长度不能超过256", groups = {Query.class})
private String experConclu;
/**
* 备注
*/
@NotBlank(message = "备注不能为空", groups = {Query.class})
@Length(max = 256, message = "备注字符长度不能超过256", groups = {Query.class})
private String remarsk;
/**
* 主要试验设备设备试验依据试验项等数据
*/
@NotBlank(message = "参数不能为空", groups = {Query.class})
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String paramsData;
/**
* 试验依据
*/
private List<ExperBasisVo> basisVos;
/**
* 试验设备
*/
private List<ConfigDevVo> deviceVos;
/**
* 试验主要设备
*/
private List<ConfigMainDevVo> mainDeviceVos;
/**
* 试验项
*/
private List<ConfigItemsVo> configItemsVos;
/**
* 查询条件限制
*/
public interface Query {
}
}

View File

@ -0,0 +1,46 @@
package com.bonus.aqgqj.basis.service;
import com.bonus.aqgqj.basis.entity.dto.ParamsDto;
import com.bonus.aqgqj.basis.entity.vo.ExperimentalDetailVo;
import com.bonus.aqgqj.basis.entity.vo.ExperimentalVo;
import com.bonus.aqgqj.utils.ServerResponse;
import java.util.List;
/**
* @className:ExperimentalService
* @author:cwchen
* @date:2024-07-20-12:09
* @version:1.0
* @description:试验管理-service
*/
public interface ExperimentalService {
/**
* 试验列表
*
* @param data
* @return List<ExperimentalVo>
* @author cwchen
* @date 2024/7/20 12:31
*/
List<ExperimentalVo> getList(ParamsDto data);
/**
* 试验详情列表
*
* @param data
* @return List<ExperimentalDetailVo>
* @author cwchen
* @date 2024/7/20 13:26
*/
List<ExperimentalDetailVo> getDetailList(ParamsDto data);
/**
* 查询试验模板数据基础数据
* @param data
* @return ServerResponse
* @author cwchen
* @date 2024/7/20 14:12
*/
ServerResponse getTestBasicInfo(ParamsDto data);
}

View File

@ -0,0 +1,89 @@
package com.bonus.aqgqj.basis.service.impl;
import com.bonus.aqgqj.basis.dao.ExperimentStandardMapper;
import com.bonus.aqgqj.basis.dao.ExperimentalMapper;
import com.bonus.aqgqj.basis.entity.dto.ParamsDto;
import com.bonus.aqgqj.basis.entity.vo.*;
import com.bonus.aqgqj.basis.service.ExperimentalService;
import com.bonus.aqgqj.utils.ServerResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* @className:ExperimentalServiceImpl
* @author:cwchen
* @date:2024-07-20-12:09
* @version:1.0
* @description:试验管理-serviceImpl
*/
@Service(value = "ExperimentalService")
@Slf4j
public class ExperimentalServiceImpl implements ExperimentalService {
@Resource(name = "ExperimentalMapper")
private ExperimentalMapper mapper;
@Resource(name = "ExperimentStandardMapper")
private ExperimentStandardMapper standardMapper;
@Override
public List<ExperimentalVo> getList(ParamsDto dto) {
List<ExperimentalVo> list = new ArrayList<>();
try {
list = mapper.getList(dto);
} catch (Exception e) {
log.error(e.toString(), e);
}
return list;
}
@Override
public List<ExperimentalDetailVo> getDetailList(ParamsDto dto) {
List<ExperimentalDetailVo> list = new ArrayList<>();
try {
list = mapper.getDetailList(dto);
if (CollectionUtils.isNotEmpty(list)) {
for (ExperimentalDetailVo detailVo : list) {
// 样品试验结果样品数量
List<ExperimentalDetailVo.Sample> sampleList = new ArrayList<>();
detailVo.setSampleList(sampleList);
detailVo.setSampleQuantity(sampleList.size());
}
}
} catch (Exception e) {
log.error(e.toString(), e);
}
return list;
}
@Override
public ServerResponse getTestBasicInfo(ParamsDto dto) {
TestVo vo = new TestVo();
try {
// 查询收样基本信息
vo = mapper.getTestBasicInfo(dto);
// 查询试验配置依据试验设备试验主要设备试验项信息
List<ExperBasisVo> basisVos= standardMapper.getExperBasis(vo.getConfigId());
List<ConfigDevVo> deviceVos = standardMapper.getConfigDev(vo.getConfigId());
List<ConfigMainDevVo> mainDevVos = standardMapper.getConfigMainDev(vo.getConfigId());
List<ConfigItemsVo> configItemsVos = standardMapper.getConfigItems(vo.getConfigId());
for (ConfigItemsVo configItemsVo : configItemsVos) {
List<ConfigItemVo> configItemVos = standardMapper.getConfiItem(configItemsVo.getId());
configItemsVo.setItemList(configItemVos);
}
vo.setBasisVos(basisVos);
vo.setDeviceVos(deviceVos);
vo.setMainDeviceVos(mainDevVos);
vo.setConfigItemsVos(configItemsVos);
} catch (Exception e) {
log.error(e.toString(), e);
}
return ServerResponse.createSuccess(vo);
}
}

View File

@ -226,7 +226,7 @@
<!--查询试验项内容-->
<select id="getConfiItem" resultType="com.bonus.aqgqj.basis.entity.vo.ConfigItemVo">
SELECT id,
items_id AS itemsId,
items_id AS itemId,
item_name AS itemName,
item_num AS itemNum
FROM tb_config_item

View File

@ -0,0 +1,77 @@
<?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.bonus.aqgqj.basis.dao.ExperimentalMapper">
<!--试验列表-->
<select id="getList" resultType="com.bonus.aqgqj.basis.entity.vo.ExperimentalVo">
SELECT ts.id,
tc.custom_name AS customName,
DATE_FORMAT(ts.sample_time, '%Y-%m-%d') AS sampleTime,
IFNULL(tsd.num,0) AS customNum,
tsd.sampleDev,
su.user_name AS sampleUserName,
su2.user_name AS dispatchUserName,
DATE_FORMAT(ts.sample_date, '%Y-%m-%d') AS sampleDate,
tt.team_name AS teamName,
ts.audti_status AS audtiStatus,
ts.process_status AS processStatus,
ts.remarks
FROM tb_sample ts
LEFT JOIN tb_custom tc ON ts.custom_id = tc.id
LEFT JOIN sys_user su ON ts.create_user = su.id AND su.del_flag = 0
LEFT JOIN sys_user su2 ON ts.update_user = su2.id AND su2.del_flag = 0
LEFT JOIN tb_team tt ON ts.team_id = tt.id AND tt.del_flag = 0
LEFT JOIN (
SELECT sample_id,COUNT(sample_id) AS num,GROUP_CONCAT(DISTINCT dev_type_name) AS sampleDev,GROUP_CONCAT(DISTINCT dev_type_code) AS sampleDevCode
FROM tb_sample_device
WHERE del_falg = 0
GROUP BY sample_id
) tsd ON tsd.sample_id = ts.id
WHERE ts.del_flag = 0 AND process_status IN (0,5)
<if test="keyWord != null and keyWord!=''">
AND (
INSTR(tt.team_name,#{keyWord}) > 0 OR
INSTR(su2.user_name,#{keyWord}) > 0
)
</if>
<if test="sampleUserName != null and sampleUserName!=''">
AND INSTR(su.user_name,#{sampleUserName}) > 0
</if>
<if test="sampleDate != null and sampleDate!=''">
AND DATE_FORMAT(ts.sample_date, '%Y-%m-%d') = #{sampleDate}
</if>
<if test="devTypeCode != null and devTypeCode!=''">
AND INSTR(tsd.sampleDevCode,#{devTypeCode})
</if>
ORDER BY dispatch_time ASC
</select>
<!--试验详情列表-->
<select id="getDetailList" resultType="com.bonus.aqgqj.basis.entity.vo.ExperimentalDetailVo">
SELECT sample_id AS sampleId,
dev_type_name AS devTypeName,
dev_type_code AS devTypeCode
FROM tb_sample_device
WHERE sample_id = #{id} AND del_falg = 0
<if test="devTypeCode != null and devTypeCode!=''">
AND INSTR(dev_type_code,#{devTypeCode})
</if>
GROUP BY dev_type_code
</select>
<!--查询试验模板数据、基础数据-->
<select id="getTestBasicInfo" resultType="com.bonus.aqgqj.basis.entity.vo.TestVo">
SELECT DATE_FORMAT(ts.sample_date, '%Y-%m-%d') AS sampleDate,
custom_id AS customId,
custom_name AS customName,
a.id AS configId
FROM tb_sample ts
LEFT JOIN (
SELECT tsd.dev_type_code,tsc.id,tsd.sample_id
FROM tb_sample_device tsd
LEFT JOIN tb_exper_config tsc ON tsc.dev_type_code = tsd.dev_type_code AND tsc.del_flag = 0
WHERE tsd.sample_id = #{id} AND tsd.del_falg = 0 AND tsd.dev_type_code = #{devTypeCode}
GROUP BY tsd.dev_type_code
) a ON a.sample_id = ts.id
WHERE ts.id = #{id} AND del_flag = 0
</select>
</mapper>