试验标准

This commit is contained in:
cwchen 2024-07-19 12:09:02 +08:00
parent c4d5d1200f
commit e9f4de6a97
15 changed files with 1242 additions and 96 deletions

View File

@ -3,9 +3,8 @@ 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.ExperimentStandardVo;
import com.bonus.aqgqj.basis.entity.vo.ExperConfigVo;
import com.bonus.aqgqj.basis.service.ExperimentStandardService;
import com.bonus.aqgqj.model.Role;
import com.bonus.aqgqj.system.vo.EncryptedReq;
import com.bonus.aqgqj.utils.ServerResponse;
import com.github.pagehelper.PageHelper;
@ -40,8 +39,38 @@ public class ExperimentStandardController {
// @PreAuthorize("@pms.hasPermission('sys:experimentStandard:query')" )
public ServerResponse getList(EncryptedReq<ParamsDto> data) {
PageHelper.startPage(data.getData().getPage(), data.getData().getLimit());
List<ExperimentStandardVo> list = service.getList(data.getData());
PageInfo<ExperimentStandardVo> pageInfo = new PageInfo<>(list);
List<ExperConfigVo> list = service.getList(data.getData());
PageInfo<ExperConfigVo> pageInfo = new PageInfo<>(list);
return ServerResponse.createSuccessPage(pageInfo,data.getData().getPage(),data.getData().getLimit());
}
@PostMapping(value = "addData")
@DecryptAndVerify(decryptedClass = ExperConfigVo.class)//加解密统一管理
@LogAnnotation(operModul = "试验标准管理", operation = "新增试验标准", operDesc = "系统级事件",operType="新增")
// @PreAuthorize("@pms.hasPermission('sys:experimentStandard:addData')" )
public ServerResponse addData(EncryptedReq<ExperConfigVo> data) {
return service.addData(data.getData());
}
@PostMapping(value = "editData")
@DecryptAndVerify(decryptedClass = ExperConfigVo.class)//加解密统一管理
@LogAnnotation(operModul = "试验标准管理", operation = "修改试验标准", operDesc = "系统级事件",operType="修改")
// @PreAuthorize("@pms.hasPermission('sys:experimentStandard:editData')" )
public ServerResponse editData(EncryptedReq<ExperConfigVo> data) {
return service.editData(data.getData());
}
@PostMapping(value = "viewData")
@DecryptAndVerify(decryptedClass = ParamsDto.class)//加解密统一管理
public ServerResponse viewData(EncryptedReq<ParamsDto> data) {
return service.viewData(data.getData());
}
@PostMapping(value = "delData")
@DecryptAndVerify(decryptedClass = ParamsDto.class)//加解密统一管理
@LogAnnotation(operModul = "试验标准管理", operation = "删除试验标准", operDesc = "系统级事件",operType="删除")
// @PreAuthorize("@pms.hasPermission('sys:experimentStandard:del')" )
public ServerResponse delData(EncryptedReq<ParamsDto> data) {
return service.delData(data.getData());
}
}

View File

@ -1,7 +1,7 @@
package com.bonus.aqgqj.basis.dao;
import com.bonus.aqgqj.basis.entity.dto.ParamsDto;
import com.bonus.aqgqj.basis.entity.vo.ExperimentStandardVo;
import com.bonus.aqgqj.basis.entity.vo.*;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -17,10 +17,220 @@ import java.util.List;
public interface ExperimentStandardMapper {
/**
* 试验标准列表
*
* @param dto
* @return List<ExperimentStandardVo>
* @return List<ExperConfigVo>
* @author cwchen
* @date 2024/7/18 14:00
*/
List<ExperimentStandardVo> getList(ParamsDto dto);
List<ExperConfigVo> getList(ParamsDto dto);
/**
* 添加试验标准配置
*
* @param experConfigVo
* @return void
* @author cwchen
* @date 2024/7/18 19:25
*/
void addExperConfig(ExperConfigVo experConfigVo);
/**
* 添加试验依据
*
* @param basisVos
* @return void
* @author cwchen
* @date 2024/7/18 19:39
*/
void addBasiss(List<ExperBasisVo> basisVos);
/**
* 添加试验设备
*
* @param deviceVos
* @return void
* @author cwchen
* @date 2024/7/18 19:46
*/
void addDev(List<ConfigDevVo> deviceVos);
/**
* 添加试验主要设备
*
* @param mainDeviceVos
* @return void
* @author cwchen
* @date 2024/7/18 19:49
*/
void addMainDev(List<ConfigMainDevVo> mainDeviceVos);
/**
* 添加试验项信息
*
* @param configItemsVo
* @return void
* @author cwchen
* @date 2024/7/18 19:57
*/
void addConfigItems(ConfigItemsVo configItemsVo);
/**
* 添加试验配置项内容
*
* @param configInfo
* @return void
* @author cwchen
* @date 2024/7/18 20:05
*/
void addConfigInfo(ExperConfigInfoVo configInfo);
/**
* 添加试验配置项内容
*
* @param itemList
* @return void
* @author cwchen
* @date 2024/7/18 20:16
*/
void addConfigItem(List<ConfigItemVo> itemList);
/**
* 验证设备类型是否存在
*
* @param vo
* @return int
* @author cwchen
* @date 2024/7/18 20:58
*/
int isExist(ExperConfigVo vo);
/**
* 查询试验标准配置
*
* @param data
* @return ExperimentStandardVo
* @author cwchen
* @date 2024/7/18 21:05
*/
ExperConfigVo getExperConfig(ParamsDto data);
/**
* 查询试验配置依据
*
* @param id
* @return List<BasisVo>
* @author cwchen
* @date 2024/7/18 21:13
*/
List<ExperBasisVo> getExperBasis(Long id);
/**
* 查询试验设备
*
* @param id
* @return List<ConfigDevVo>
* @author cwchen
* @date 2024/7/18 21:15
*/
List<ConfigDevVo> getConfigDev(Long id);
/**
* 查询试验主要设备
*
* @param id
* @return List<ConfigMainDevVo>
* @author cwchen
* @date 2024/7/19 9:10
*/
List<ConfigMainDevVo> getConfigMainDev(Long id);
/**
* 查询试验项信息
*
* @param id
* @return List<ConfigItemsVo>
* @author cwchen
* @date 2024/7/19 9:18
*/
List<ConfigItemsVo> getConfigItems(Long id);
/**
* 查询试验项内容
*
* @param id
* @return List<ConfigItemVo>
* @author cwchen
* @date 2024/7/19 9:23
*/
List<ConfigItemVo> getConfiItem(Long id);
/**
* 删除试验项
*
* @param list
* @return void
* @author cwchen
* @date 2024/7/19 10:20
*/
void delItems(List<ConfigItemsVo> list);
/**
* 删除试验标准配置
*
* @param dto
* @return void
* @author cwchen
* @date 2024/7/19 10:36
*/
void delExperConfig(ParamsDto dto);
/**
* 删除试验依据
*
* @param dto
* @return void
* @author cwchen
* @date 2024/7/19 10:36
*/
void delExperBasis(ParamsDto dto);
/**
* 删除试验设备
*
* @param dto
* @return void
* @author cwchen
* @date 2024/7/19 10:36
*/
void delConfigDev(ParamsDto dto);
/**
* 删除试验主要设备
*
* @param dto
* @return void
* @author cwchen
* @date 2024/7/19 10:37
*/
void delConfigManDev(ParamsDto dto);
/**
* 删除试验项内容
*
* @param configItemsVos
* @return void
* @author cwchen
* @date 2024/7/19 10:39
*/
void delItem(List<ConfigItemsVo> configItemsVos);
/**
* 修改试验标准配置
* @param experConfigVo
* @return void
* @author cwchen
* @date 2024/7/19 10:50
*/
void editExperConfig(ExperConfigVo experConfigVo);
}

View File

@ -1,6 +1,7 @@
package com.bonus.aqgqj.basis.entity.dto;
import com.bonus.aqgqj.base.entity.PageEntity;
import lombok.Data;
/**
* @className:ParamsDto
@ -9,7 +10,12 @@ import com.bonus.aqgqj.base.entity.PageEntity;
* @version:1.0
* @description:params-dto
*/
@Data
public class ParamsDto extends PageEntity {
/**
* id
*/
private Long id;
/**
* 设备类型

View File

@ -0,0 +1,38 @@
package com.bonus.aqgqj.basis.entity.vo;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
/**
* @className:ConfigDevVo
* @author:cwchen
* @date:2024-07-18-18:51
* @version:1.0
* @description:试验设备配置表
*/
@Data
public class ConfigDevVo {
/**ID*/
private Long id;
/**设备类型编码*/
private String devTypeCode;
/**设备类型名称*/
private String devTypeName;
/** 配置项id*/
private Long configId;
/**试验设备名称*/
@NotBlank(message = "试验设备名称不能为空", groups = {Query.class})
@Length(max = 128, message = "试验设备名称字符长度不能超过128", groups = {Query.class})
private String devName;
/**实验设备id*/
private Long devId;
/**
* 查询条件限制
*/
public interface Query {
}
}

View File

@ -0,0 +1,47 @@
package com.bonus.aqgqj.basis.entity.vo;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @className:ConfigItemsVo
* @author:cwchen
* @date:2024-07-18-15:41
* @version:1.0
* @description:试验内容信息-vo
*/
@Data
public class ConfigItemVo {
/**
* 试验内容id
*/
private Long id;
/**
* 试验项id
*/
private Long itemId;
/**
* 试验项内容
*/
@NotBlank(message = "试验项内容不能为空", groups = {Query.class})
@Length(max = 128, message = "试验项内容字符长度不能超过128", groups = {Query.class})
private String itemName;
/**
* 试验项排序
*/
@NotNull(message = "试验项排序不能为空", groups = {Query.class})
private Integer itemNum;
/**
* 查询条件限制
*/
public interface Query {
}
}

View File

@ -0,0 +1,71 @@
package com.bonus.aqgqj.basis.entity.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.List;
/**
* @className:ConfigItemsVo
* @author:cwchen
* @date:2024-07-18-15:41
* @version:1.0
* @description:试验项信息-vo
*/
@Data
public class ConfigItemsVo {
/**
* 试验项id
*/
private Long id;
/**
* 试验项类型编码
*/
private String experTypeCode;
/**
* 实验项类型名称
*/
@NotBlank(message = "实验项类型名称不能为空", groups = {Query.class})
@Length(max = 128, message = "实验项类型名称字符长度不能超过128", groups = {Query.class})
private String experTypeName;
/**
* 实验项内容数量
*/
@NotNull(message = "实验项内容数量不能为空", groups = {Query.class})
private Integer experNum;
/**
* 排序
*/
@NotNull(message = "试验项排序不能为空", groups = {Query.class})
private Integer itemsSort;
/**
* 金额
*/
@NotBlank(message = "金额不能为空", groups = {Query.class})
@Pattern(regexp = "[0-9]{1,8}(,[0-9]{8})*(.[0-9]{1,2})?", message = "金额格式不正确", groups = {Query.class})
private String amount;
/**
* 配置项
*/
@NotBlank(message = "试验项内容不能为空", groups = {Query.class})
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String item;
/**
* 试验项内容信息
*/
private List<ConfigItemVo> itemList;
/**
* 查询条件限制
*/
public interface Query {
}
}

View File

@ -0,0 +1,54 @@
package com.bonus.aqgqj.basis.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
/**
* @className:ConfigMainDevVo
* @author:cwchen
* @date:2024-07-18-18:51
* @version:1.0
* @description:试验主要设备配置-vo
*/
@Data
public class ConfigMainDevVo {
/**ID*/
private Long id;
/** 配置项id*/
private Long configId;
/**设备类型编码*/
private String devTypeCode;
/**设备类型名称*/
private String devTypeName;
/**实验设备id*/
private String experId;
/**试验主要设备名称*/
@NotBlank(message = "试验主要设备名称不能为空", groups = {Query.class})
@Length(max = 64, message = "试验主要设备名称字符长度不能超过64", groups = {Query.class})
private String experDevName;
/**设备型号*/
@NotBlank(message = "试验主要设备型号不能为空", groups = {Query.class})
@Length(max = 64, message = "试验主要设备字符长度不能超过64", groups = {Query.class})
private String experDevModule;
/**编号*/
@NotBlank(message = "试验主要设备编号名称不能为空", groups = {Query.class})
@Length(max = 64, message = "试验主要设备编号字符长度不能超过64", groups = {Query.class})
private String experDevCode;
/**合同生效日期*/
@NotBlank(message = "合同生效日期不能为空", groups = {Query.class})
@Pattern(regexp = "\\d{4}(\\-|\\/|\\.)\\d{1,2}\\1\\d{1,2}", message = "合同生效日期格式不正确", groups = {Query.class})
private String devContractDate;
/**
* 查询条件限制
*/
public interface Query {
}
}

View File

@ -0,0 +1,33 @@
package com.bonus.aqgqj.basis.entity.vo;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
/**
* @className:ExperBasisVo
* @author:cwchen
* @date:2024-07-18-18:48
* @version:1.0
* @description:试验依据-vo
*/
@Data
public class ExperBasisVo {
private Long id;
/**试验标准配置ID*/
private Long configId;
/**试验依据*/
@NotBlank(message = "试验依据不能为空", groups = {Query.class})
@Length(max = 128, message = "试验依据字符长度不能超过128", groups = {Query.class})
private String basisName;
/**
* 查询条件限制
*/
public interface Query {
}
}

View File

@ -0,0 +1,35 @@
package com.bonus.aqgqj.basis.entity.vo;
import lombok.Data;
/**
* @className:ExperConfigInfoVo
* @author:cwchen
* @date:2024-07-18-20:02
* @version:1.0
* @description:试验配置项内容-vo
*/
@Data
public class ExperConfigInfoVo {
/**
* id
*/
private Long id;
/**
* 设备类型id
*/
private String devTypeId;
/**
* 设备类型名称
*/
private String devTypeName;
/**
* 配置id
*/
private Long configId;
/**
* 试验项id
*/
private Long itemId;
}

View File

@ -0,0 +1,113 @@
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:ExperConfigVo
* @author:cwchen
* @date:2024-07-18-11:21
* @version:1.0
* @description:试验标准配置-vo
*/
@Data
public class ExperConfigVo {
/**
* id
*/
private Long id;
/**
* 设备类型编码
*/
@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")
private Date updateTime = new Date();
/**
* 主要试验设备设备试验依据试验项等数据
*/
@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

@ -1,68 +0,0 @@
package com.bonus.aqgqj.basis.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.Date;
/**
* @className:ExperimentStandardVo
* @author:cwchen
* @date:2024-07-18-11:21
* @version:1.0
* @description:试验标准-vo
*/
@Data
public class ExperimentStandardVo {
/**
* id
*/
private Long id;
/**
* 设备类型编码
*/
private String devTypeCode;
/**
* 设备类型名称
*/
private String devTypeName;
/**
* 设备规格型号
*/
private String devModule;
/**
* 实验地点编码
*/
private String experLocalCode;
/**
* 实验地点
*/
private String experLocal;
/**
* 删除状态
*/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Integer delFlag = 0;
/**
* 创建人
*/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Long createUser;
/**
* 创建时间
*/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/**
* 修改人
*/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Long updateUser;
/**
* 修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}

View File

@ -1,7 +1,8 @@
package com.bonus.aqgqj.basis.service;
import com.bonus.aqgqj.basis.entity.dto.ParamsDto;
import com.bonus.aqgqj.basis.entity.vo.ExperimentStandardVo;
import com.bonus.aqgqj.basis.entity.vo.ExperConfigVo;
import com.bonus.aqgqj.utils.ServerResponse;
import java.util.List;
@ -15,10 +16,50 @@ import java.util.List;
public interface ExperimentStandardService {
/**
* 试验标准列表
*
* @param data
* @return List<ExperimentStandardVo>
* @return List<ExperConfigVo>
* @author cwchen
* @date 2024/7/18 13:58
*/
List<ExperimentStandardVo> getList(ParamsDto data);
List<ExperConfigVo> getList(ParamsDto data);
/**
* 新增试验标准
*
* @param data
* @return ServerResponse
* @author cwchen
* @date 2024/7/18 14:54
*/
ServerResponse addData(ExperConfigVo data);
/**
* 试验标准详情
*
* @param data
* @return ServerResponse
* @author cwchen
* @date 2024/7/18 21:02
*/
ServerResponse viewData(ParamsDto data);
/**
* 删除试验标准
*
* @param data
* @return ServerResponse
* @author cwchen
* @date 2024/7/19 10:13
*/
ServerResponse delData(ParamsDto data);
/**
* 修改试验标准配置
* @param data
* @return ServerResponse
* @author cwchen
* @date 2024/7/19 10:48
*/
ServerResponse editData(ExperConfigVo data);
}

View File

@ -1,12 +1,22 @@
package com.bonus.aqgqj.basis.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bonus.aqgqj.advice.ValidatorsUtils;
import com.bonus.aqgqj.basis.dao.ExperimentStandardMapper;
import com.bonus.aqgqj.basis.entity.dto.ParamsDto;
import com.bonus.aqgqj.basis.entity.vo.ExperimentStandardVo;
import com.bonus.aqgqj.basis.entity.vo.*;
import com.bonus.aqgqj.basis.service.ExperimentStandardService;
import com.bonus.aqgqj.utils.ServerResponse;
import com.bonus.aqgqj.webResult.Constants;
import com.bonus.aqgqj.webResult.HttpStatus;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
import java.util.ArrayList;
@ -30,8 +40,8 @@ public class ExperimentStandardServiceImpl implements ExperimentStandardService
private ValidatorsUtils validatorsUtils;
@Override
public List<ExperimentStandardVo> getList(ParamsDto dto) {
List<ExperimentStandardVo> list = new ArrayList<>();
public List<ExperConfigVo> getList(ParamsDto dto) {
List<ExperConfigVo> list = new ArrayList<>();
try {
list = mapper.getList(dto);
return list;
@ -40,4 +50,308 @@ public class ExperimentStandardServiceImpl implements ExperimentStandardService
}
return list;
}
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResponse addData(ExperConfigVo vo) {
try {
// 整体数据校验数据
String validResult = validatorsUtils.valid(vo, ExperConfigVo.Query.class);
if (StringUtils.isNotBlank(validResult)) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, validResult);
}
// 验证设备类型是否重复添加
int num = mapper.isExist(vo);
if(num > 0){
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "设备类型已存在,请勿重复添加");
}
String result = validatorsParams(vo.getParamsData());
if (StringUtils.isNotBlank(result)) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, result);
}
ExperConfigVo experConfigVo = handleConfigItem(vo);
if (experConfigVo == null) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "参数异常");
}
// 试验设备试验主要设备试验依据试验项校验
String result2 = singleValidators(experConfigVo);
if (StringUtils.isNotBlank(result2)) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, result2);
}
// 添加试验标准配置
mapper.addExperConfig(experConfigVo);
for (ExperBasisVo basisVo : experConfigVo.getBasisVos()) {
basisVo.setConfigId(experConfigVo.getId());
}
// 添加试验依据
mapper.addBasiss(experConfigVo.getBasisVos());
// 添加试验设备
for (ConfigDevVo deviceVo : experConfigVo.getDeviceVos()) {
deviceVo.setConfigId(experConfigVo.getId());
}
mapper.addDev(experConfigVo.getDeviceVos());
// 添加试验主要设备
for (ConfigMainDevVo mainDeviceVo : experConfigVo.getMainDeviceVos()) {
mainDeviceVo.setConfigId(experConfigVo.getId());
}
mapper.addMainDev(experConfigVo.getMainDeviceVos());
// 添加试验项信息
for (ConfigItemsVo configItemsVo : experConfigVo.getConfigItemsVos()) {
mapper.addConfigItems(configItemsVo);
// 添加试验配置项内容
ExperConfigInfoVo configInfo = new ExperConfigInfoVo();
configInfo.setConfigId(experConfigVo.getId());
configInfo.setItemId(configItemsVo.getId());
mapper.addConfigInfo(configInfo);
for (ConfigItemVo configItemVo : configItemsVo.getItemList()) {
configItemVo.setItemId(configItemsVo.getId());
}
// 添加试验配置项内容
mapper.addConfigItem(configItemsVo.getItemList());
}
} catch (Exception e) {
log.error(e.toString(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return ServerResponse.createByErrorMsg(HttpStatus.ERROR,"操作失败");
}
return ServerResponse.createBySuccessMsg("操作成功");
}
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResponse editData(ExperConfigVo vo) {
try {
// 整体数据校验数据
String validResult = validatorsUtils.valid(vo, ExperConfigVo.Query.class);
if (StringUtils.isNotBlank(validResult)) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, validResult);
}
// 验证设备类型是否重复添加
int num = mapper.isExist(vo);
if(num > 0){
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "设备类型已存在,请勿重复添加");
}
String result = validatorsParams(vo.getParamsData());
if (StringUtils.isNotBlank(result)) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, result);
}
ExperConfigVo experConfigVo = handleConfigItem(vo);
if (experConfigVo == null) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "参数异常");
}
// 试验设备试验主要设备试验依据试验项校验
String result2 = singleValidators(experConfigVo);
if (StringUtils.isNotBlank(result2)) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, result2);
}
// 先删除试验依据试验设备试验主要设备试验项试验项内容后 在进行重新添加
ParamsDto dto = new ParamsDto();
dto.setId(experConfigVo.getId());
mapper.delExperBasis(dto);
mapper.delConfigDev(dto);
mapper.delConfigManDev(dto);
List<ConfigItemsVo> configItemsVos = mapper.getConfigItems(dto.getId());
mapper.delItems(configItemsVos);
mapper.delItem(configItemsVos);
// 修改试验标准配置
mapper.editExperConfig(experConfigVo);
for (ExperBasisVo basisVo : experConfigVo.getBasisVos()) {
basisVo.setConfigId(experConfigVo.getId());
}
// 添加试验依据
mapper.addBasiss(experConfigVo.getBasisVos());
// 添加试验设备
for (ConfigDevVo deviceVo : experConfigVo.getDeviceVos()) {
deviceVo.setConfigId(experConfigVo.getId());
}
mapper.addDev(experConfigVo.getDeviceVos());
// 添加试验主要设备
for (ConfigMainDevVo mainDeviceVo : experConfigVo.getMainDeviceVos()) {
mainDeviceVo.setConfigId(experConfigVo.getId());
}
mapper.addMainDev(experConfigVo.getMainDeviceVos());
// 添加试验项信息
for (ConfigItemsVo configItemsVo : experConfigVo.getConfigItemsVos()) {
mapper.addConfigItems(configItemsVo);
// 添加试验配置项内容
ExperConfigInfoVo configInfo = new ExperConfigInfoVo();
configInfo.setConfigId(experConfigVo.getId());
configInfo.setItemId(configItemsVo.getId());
mapper.addConfigInfo(configInfo);
for (ConfigItemVo configItemVo : configItemsVo.getItemList()) {
configItemVo.setItemId(configItemsVo.getId());
}
// 添加试验配置项内容
mapper.addConfigItem(configItemsVo.getItemList());
}
} catch (Exception e) {
log.error(e.toString(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return ServerResponse.createByErrorMsg(HttpStatus.ERROR,"操作失败");
}
return ServerResponse.createBySuccessMsg("操作成功");
}
@Override
public ServerResponse viewData(ParamsDto data) {
if(data.getId() == null){
return ServerResponse.createByErrorMsg(HttpStatus.ERROR,"请求参数不完整");
}
ExperConfigVo vo = null;
try {
vo = mapper.getExperConfig(data);
// 查询试验配置依据试验设备试验主要设备试验项信息
List<ExperBasisVo> basisVos= mapper.getExperBasis(vo.getId());
List<ConfigDevVo> deviceVos = mapper.getConfigDev(vo.getId());
List<ConfigMainDevVo> mainDevVos = mapper.getConfigMainDev(vo.getId());
List<ConfigItemsVo> configItemsVos = mapper.getConfigItems(vo.getId());
for (ConfigItemsVo configItemsVo : configItemsVos) {
List<ConfigItemVo> configItemVos = mapper.getConfiItem(configItemsVo.getId());
configItemsVo.setItemList(configItemVos);
}
vo.setBasisVos(basisVos);
vo.setDeviceVos(deviceVos);
vo.setMainDeviceVos(mainDevVos);
vo.setConfigItemsVos(configItemsVos);
return ServerResponse.createSuccess(vo);
} catch (Exception e) {
log.error(e.toString(),e);
return ServerResponse.createByErrorMsg(HttpStatus.ERROR,"查询失败");
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResponse delData(ParamsDto dto) {
try {
mapper.delExperConfig(dto);
mapper.delExperBasis(dto);
mapper.delConfigDev(dto);
mapper.delConfigManDev(dto);
List<ConfigItemsVo> configItemsVos = mapper.getConfigItems(dto.getId());
mapper.delItems(configItemsVos);
mapper.delItem(configItemsVos);
} catch (Exception e) {
log.error(e.toString(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return ServerResponse.createByErrorMsg(HttpStatus.ERROR,"操作失败");
}
return ServerResponse.createBySuccessMsg("操作成功");
}
/**
* 验证参数是否为空
*
* @param value
* @return String
* @author cwchen
* @date 2024/7/18 17:22
*/
public String validatorsParams(String value) {
try {
// 试验配置项试验依据试验设备主要试验设备验证数据是否为空
JSONObject obj = JSONObject.parseObject(value);
JSONArray itemsList = obj.getJSONArray("items");
JSONArray yjList = obj.getJSONArray("yjList");
JSONArray devList = obj.getJSONArray("devList");
JSONArray mainDevList = obj.getJSONArray("mainDevList");
if (CollectionUtils.isEmpty(devList)) {
return Constants.ERROR_1;
}
if (CollectionUtils.isEmpty(mainDevList)) {
return Constants.ERROR_2;
}
if (CollectionUtils.isEmpty(yjList)) {
return Constants.ERROR_3;
}
if (CollectionUtils.isEmpty(itemsList)) {
return Constants.ERROR_4;
}
} catch (Exception e) {
log.error(e.toString(), e);
return Constants.ERROR_5;
}
return null;
}
/**
* 处理试验项试验项内容试验依据试验设备主要试验设备数据
*
* @param vo
* @return List<ConfigItemsVo>
* @author cwchen
* @date 2024/7/18 16:43
*/
public ExperConfigVo handleConfigItem(ExperConfigVo vo) {
try {
JSONObject obj = JSONObject.parseObject(vo.getParamsData());
JSONArray yjList = obj.getJSONArray("yjList");
JSONArray devList = obj.getJSONArray("devList");
JSONArray mainDevList = obj.getJSONArray("mainDevList");
JSONArray itemsList = obj.getJSONArray("items");
List<ExperBasisVo> basisVos = yjList.toJavaList(ExperBasisVo.class);
List<ConfigDevVo> deviceVos = devList.toJavaList(ConfigDevVo.class);
List<ConfigMainDevVo> mainDeviceVos = mainDevList.toJavaList(ConfigMainDevVo.class);
List<ConfigItemsVo> configItemsVos = itemsList.toJavaList(ConfigItemsVo.class);
for (ConfigItemsVo configItemsVo : configItemsVos) {
JSONArray itemArr = JSONObject.parseArray(configItemsVo.getItem());
List<ConfigItemVo> configItemVos = itemArr.toJavaList(ConfigItemVo.class);
configItemsVo.setItemList(configItemVos);
}
vo.setBasisVos(basisVos);
vo.setDeviceVos(deviceVos);
vo.setMainDeviceVos(mainDeviceVos);
vo.setConfigItemsVos(configItemsVos);
} catch (Exception e) {
log.error(e.toString(), e);
return null;
}
return vo;
}
/**
* 试验项试验项内容试验依据试验设备主要试验设备数据校验
*
* @param vo
* @return String
* @author cwchen
* @date 2024/7/18 19:17
*/
public String singleValidators(ExperConfigVo vo) {
List<ConfigDevVo> deviceVos = vo.getDeviceVos();
List<ConfigMainDevVo> mainDeviceVos = vo.getMainDeviceVos();
List<ExperBasisVo> basisVos = vo.getBasisVos();
List<ConfigItemsVo> configItemsVos = vo.getConfigItemsVos();
for (ConfigDevVo deviceVo : deviceVos) {
String validResult = validatorsUtils.valid(vo, ConfigDevVo.Query.class);
if (StringUtils.isNotBlank(validResult)) {
return validResult;
}
}
for (ConfigMainDevVo mainDeviceVo : mainDeviceVos) {
String validResult = validatorsUtils.valid(vo, ConfigMainDevVo.Query.class);
if (StringUtils.isNotBlank(validResult)) {
return validResult;
}
}
for (ExperBasisVo basisVo : basisVos) {
String validResult = validatorsUtils.valid(vo, ExperBasisVo.Query.class);
if (StringUtils.isNotBlank(validResult)) {
return validResult;
}
}
for (ConfigItemsVo configItemsVo : configItemsVos) {
String validResult = validatorsUtils.valid(vo, ConfigItemsVo.Query.class);
if (StringUtils.isNotBlank(validResult)) {
return validResult;
}
for (ConfigItemVo configItemVo : configItemsVo.getItemList()) {
String validResult2 = validatorsUtils.valid(vo, ConfigItemVo.Query.class);
if (StringUtils.isNotBlank(validResult2)) {
return validResult2;
}
}
}
return null;
}
}

View File

@ -131,4 +131,10 @@ public class Constants
public static final String UN_KNOW = "unknow";
public static final String ERROR_IP = "0:0:0:0:0:0:0:1";
public static final String ERROR_1 = "试验设备不能为空";
public static final String ERROR_2 = "主要试验设备不能为空";
public static final String ERROR_3 = "试验依据不能为空";
public static final String ERROR_4 = "试验项不能为空";
public static final String ERROR_5 = "参数不能为空";
}

View File

@ -2,9 +2,150 @@
<!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.ExperimentStandardMapper">
<!--添加试验标准配置-->
<insert id="addExperConfig" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_exper_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="devTypeCode != null and devTypeCode != ''">dev_type_code,</if>
<if test="devTypeName != null and devTypeName != ''">dev_type_name,</if>
<if test="devModule != null and devModule != ''">dev_module,</if>
<if test="experLocalCode != null and experLocalCode!=''">exper_local_code,</if>
<if test="experLocal != null and experLocal!=''">exper_local,</if>
del_flag,
create_user,
create_time,
update_user,
update_time,
id
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="devTypeCode != null and devTypeCode != ''">#{devTypeCode},</if>
<if test="devTypeName != null and devTypeName != ''">#{devTypeName},</if>
<if test="devModule != null and devModule != ''">#{devModule},</if>
<if test="experLocalCode != null and experLocalCode != ''">#{experLocalCode},</if>
<if test="experLocal != null and experLocal!=''">#{experLocal},</if>
0,
#{createUser},
#{createTime},
#{updateUser},
#{updateTime},
null
</trim>
</insert>
<!--添加试验依据-->
<insert id="addBasiss">
INSERT INTO tb_exper_basis(id,config_id,basis_name) VALUES
<foreach collection="basisVos" separator="," item="item">
(
null,#{item.configId},#{item.basisName}
)
</foreach>
</insert>
<!--添加试验设备-->
<insert id="addDev">
INSERT INTO tb_config_dev(id,dev_type_code,dev_type_name,config_id,dev_name,dev_id) VALUES
<foreach collection="deviceVos" separator="," item="item">
(
null,#{item.devTypeCode},#{item.devTypeName},#{item.configId},#{item.devName},#{item.devId}
)
</foreach>
</insert>
<!--添加试验主要设备-->
<insert id="addMainDev">
INSERT INTO tb_config_man_dev(id,config_id,dev_type_code,dev_type_name,exper_id,exper_dev_name,exper_dev_module,exper_dev_code,dev_contract_date) VALUES
<foreach collection="mainDeviceVos" separator="," item="item">
(
null,#{item.configId},#{item.devTypeCode},#{item.devTypeName},#{item.experId},#{item.experDevName},#{item.experDevModule},#{item.experDevCode},#{item.devContractDate}
)
</foreach>
</insert>
<!--添加试验项信息-->
<insert id="addConfigItems" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_config_items
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="experTypeCode != null and experTypeCode != ''">exper_type_code,</if>
<if test="experTypeName != null and experTypeName != ''">exper_type_name,</if>
<if test="experNum != null">exper_num,</if>
<if test="itemsSort != null">items_sort,</if>
<if test="amount != null and amount!=''">amount,</if>
id
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="experTypeCode != null and experTypeCode != ''">#{experTypeCode},</if>
<if test="experTypeName != null and experTypeName != ''">#{experTypeName},</if>
<if test="experNum != null">#{experNum},</if>
<if test="itemsSort != null">#{itemsSort},</if>
<if test="amount != null and amount!=''">#{amount},</if>
null
</trim>
</insert>
<!--添加试验配置项内容-->
<insert id="addConfigInfo">
INSERT INTO tb_exper_config_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="devTypeId != null and devTypeId != ''">dev_type_id,</if>
<if test="devTypeName != null and devTypeName != ''">dev_type_name,</if>
<if test="configId != null">config_id,</if>
<if test="itemId != null">item_id,</if>
id
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="devTypeId != null and devTypeId != ''">#{devTypeId},</if>
<if test="devTypeName != null and devTypeName != ''">#{devTypeName},</if>
<if test="configId != null">#{configId},</if>
<if test="itemId != null">#{itemId},</if>
null
</trim>
</insert>
<!--添加试验配置项内容-->
<insert id="addConfigItem">
INSERT INTO tb_config_item(id,items_id,item_name,item_num,del_flage) VALUES
<foreach collection="itemList" separator="," item="item">
(
null,#{item.itemId},#{item.itemName},#{item.itemNum},0
)
</foreach>
</insert>
<!--修改试验标准配置-->
<update id="editExperConfig">
UPDATE tb_exper_config SET dev_type_code = #{devTypeCode},dev_type_name = #{devTypeName},dev_module = #{devModule},
exper_local_code = #{experLocalCode},exper_local = #{experLocal},update_user = #{updateUser},update_time = #{updateTime} WHERE id = #{id}
</update>
<!--删除试验项-->
<delete id="delItems">
DELETE FROM tb_config_items
WHERE id IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item.id}
</foreach>
</delete>
<!--删除试验标准配置-->
<delete id="delExperConfig">
UPDATE tb_exper_config SET del_flag = 1 WHERE id = #{id}
</delete>
<!--删除试验依据-->
<delete id="delExperBasis">
DELETE FROM tb_exper_basis WHERE config_id = #{id}
</delete>
<!--删除试验设备-->
<delete id="delConfigDev">
DELETE FROM tb_config_dev WHERE config_id = #{id}
</delete>
<!--删除试验主要设备-->
<delete id="delConfigManDev">
DELETE FROM tb_config_man_dev WHERE config_id = #{id}
</delete>
<!--删除试验项内容-->
<delete id="delItem">
DELETE FROM tb_config_item
WHERE items_id IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item.id}
</foreach>
</delete>
<!--试验标准列表-->
<select id="getList" resultType="com.bonus.aqgqj.basis.entity.vo.ExperimentStandardVo">
<select id="getList" resultType="com.bonus.aqgqj.basis.entity.vo.ExperConfigVo">
SELECT id,
dev_type_code AS devTypeCode,
dev_type_name AS devTypeName,
@ -14,6 +155,82 @@
<if test="devTypeCode!=null and devTypeCode!=''">
dev_type_code = #{devTypeCode}
</if>
AND del_flag = 0
</where>
</select>
<!--验证设备类型是否存在-->
<select id="isExist" resultType="java.lang.Integer">
<if test="id == null">
SELECT COUNT(*) FROM tb_exper_config WHERE dev_type_code = #{devTypeCode} AND del_flag = 0
</if>
<if test="id != null">
SELECT COUNT(*) FROM tb_exper_config WHERE dev_type_code = #{devTypeCode} AND id != #{id} AND del_flag = 0
</if>
</select>
<!--查询试验标准配置-->
<select id="getExperConfig" resultType="com.bonus.aqgqj.basis.entity.vo.ExperConfigVo">
SELECT id,
dev_type_code AS devTypeCode,
dev_type_name AS devTypeName,
dev_module AS devModule,
exper_local_code AS experLocalCode,
exper_local AS experLocal
FROM tb_exper_config
WHERE id = #{id}
</select>
<!--查询试验配置依据-->
<select id="getExperBasis" resultType="com.bonus.aqgqj.basis.entity.vo.ExperBasisVo">
SELECT id,
config_id AS configId,
basis_name AS basisName
FROM tb_exper_basis WHERE config_id = #{id}
</select>
<!--查询试验设备-->
<select id="getConfigDev" resultType="com.bonus.aqgqj.basis.entity.vo.ConfigDevVo">
SELECT id,
dev_type_code AS devTypeCode,
dev_type_name AS devTypeName,
dev_name AS devName,
dev_id AS devId,
config_id AS configId
FROM tb_config_dev
WHERE config_id = #{id}
</select>
<!--查询试验主要设备-->
<select id="getConfigMainDev" resultType="com.bonus.aqgqj.basis.entity.vo.ConfigMainDevVo">
SELECT id,
config_id AS configId,
dev_type_code AS devTypeCode,
dev_type_name AS devTypeName,
exper_id AS exPerId,
exper_dev_name AS experDevName,
exper_dev_module AS experDevModule,
exper_dev_code AS experDevCode,
DATE_FORMAT(dev_contract_date, '%Y-%m-%d') AS devContractDate
FROM tb_config_man_dev
WHERE config_id = #{id}
</select>
<!--查询试验项信息-->
<select id="getConfigItems" resultType="com.bonus.aqgqj.basis.entity.vo.ConfigItemsVo">
SELECT tci.id,
tci.exper_type_code AS experTypeCode,
tci.exper_type_name AS experTypeName,
tci.exper_num AS experNum,
tci.items_sort AS itemsSort,
tci.amount
FROM tb_config_items tci
LEFT JOIN tb_exper_config_info teci ON tci.id = teci.item_id
WHERE teci.config_id = #{id}
ORDER BY items_sort
</select>
<!--查询试验项内容-->
<select id="getConfiItem" resultType="com.bonus.aqgqj.basis.entity.vo.ConfigItemVo">
SELECT id,
items_id AS itemsId,
item_name AS itemName,
item_num AS itemNum
FROM tb_config_item
WHERE items_id = #{id} AND del_flage = 0
ORDER BY item_num
</select>
</mapper>