试验实施3个过程支持暂存功能
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package org.jeecg.modules.database.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum StageDataType {
|
||||
|
||||
RADIATION_PROCESS(1, "辐照过程"),
|
||||
TEST_PROCESS(2, "测试过程"),
|
||||
ANNEAL_PROCESS(3, "测试过程"),
|
||||
|
||||
;
|
||||
|
||||
|
||||
final int code;
|
||||
final String name;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package org.jeecg.modules.database.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.modules.database.entity.StageData;
|
||||
import org.jeecg.modules.database.service.IStageDataService;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Tag(name = "试验实施暂存数据API")
|
||||
@RestController
|
||||
@RequestMapping("/database/stageData")
|
||||
@Slf4j
|
||||
public class StageDataController extends JeecgController<StageData, IStageDataService> {
|
||||
@Autowired
|
||||
private IStageDataService stageDataService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(StageDataController.class);
|
||||
|
||||
|
||||
@AutoLog(value = "器件搜索数据-添加")
|
||||
@Operation(summary = "器件搜索数据-添加")
|
||||
@PostMapping(value = "/addOrModify")
|
||||
public Result<String> add(@RequestBody StageData stageData, HttpServletRequest request) {
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
SysUser userByName = userService.getUserByName(username);
|
||||
Boolean result;
|
||||
Date currentDate = new Date();
|
||||
stageData.setCreateTime(currentDate);
|
||||
stageData.setUpdateTime(currentDate);
|
||||
stageData.setCreateBy(userByName.getId());
|
||||
stageData.setUpdateBy(userByName.getId());
|
||||
try {
|
||||
result = stageDataService.saveOrUpdateByBizId(stageData);
|
||||
}catch (JeecgBootException e) {
|
||||
logger.error("系统错误",e.getMessage());
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
return Result.error("保存失败!");
|
||||
}else {
|
||||
return Result.OK("保存成功!");
|
||||
}
|
||||
}
|
||||
|
||||
@AutoLog(value = "器件搜索数据-通过bizId查询")
|
||||
@Operation(summary = "器件搜索数据-通过bizId查询")
|
||||
@GetMapping(value = "/queryByBizId")
|
||||
public Result<StageData> queryByBizId(@RequestParam(name="bizId") String bizId, @RequestParam(name="dataType") int dataType) {
|
||||
StageData stageData = null;
|
||||
try {
|
||||
stageData = stageDataService.queryStageDataByBizId(bizId, dataType);
|
||||
}catch (JeecgBootException e) {
|
||||
logger.error("系统错误",e.getMessage());
|
||||
}
|
||||
|
||||
return Result.OK(stageData);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package org.jeecg.modules.database.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 暂存数据实体,
|
||||
* 支持: 试验实施的 辐照过程,测试过程,退火过程数据的暂存
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode
|
||||
@Schema(description = "暂存的数据")
|
||||
@TableName("stage_data")
|
||||
public class StageData implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Schema(description = "创建人")
|
||||
private String createBy;
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
|
||||
@Schema(description = "创建日期")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@Schema(description = "更新人")
|
||||
private String updateBy;
|
||||
/**
|
||||
* 更新日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
|
||||
@Schema(description = "更新日期")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 业务ID,暂存数据对应的业务ID,比如: 辐照ID, 测试ID,退火ID
|
||||
*/
|
||||
private String bizId;
|
||||
|
||||
/**
|
||||
* 暂存的数据来源,参考枚举 @StageDataType
|
||||
*
|
||||
*/
|
||||
@Schema(description = "数据类型")
|
||||
private int dataType = 3;
|
||||
/**
|
||||
* 暂存的数据
|
||||
*/
|
||||
@Schema(description = "暂存的数据")
|
||||
private String content;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.jeecg.modules.database.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.database.entity.StageData;
|
||||
|
||||
public interface StageDataMapper extends BaseMapper<StageData> {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.jeecg.modules.database.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.database.entity.StageData;
|
||||
|
||||
|
||||
public interface IStageDataService extends IService<StageData> {
|
||||
boolean saveOrUpdateByBizId(StageData stageData);
|
||||
StageData queryStageDataByBizId(String bizId, int dataType);
|
||||
|
||||
void deleteByBizId(String bizId);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.jeecg.modules.database.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jodd.util.StringUtil;
|
||||
import org.jeecg.modules.database.entity.StageData;
|
||||
import org.jeecg.modules.database.mapper.StageDataMapper;
|
||||
import org.jeecg.modules.database.service.IStageDataService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
public class StageDataServiceImpl extends ServiceImpl<StageDataMapper, StageData> implements IStageDataService {
|
||||
@Override
|
||||
public boolean saveOrUpdateByBizId(StageData stageData) {
|
||||
boolean result = false;
|
||||
if (stageData != null && StringUtil.isNotBlank(stageData.getBizId())) {
|
||||
StageData stageDataByBizId = this.getOne(new LambdaQueryWrapper<StageData>().eq(StageData::getBizId, stageData.getBizId()));
|
||||
if (stageDataByBizId != null) {
|
||||
stageDataByBizId.setId(stageDataByBizId.getId());
|
||||
stageDataByBizId.setUpdateTime(new Date());
|
||||
result = saveOrUpdate(stageDataByBizId);
|
||||
}else {
|
||||
stageData.setCreateTime(new Date());
|
||||
stageData.setUpdateTime(new Date());
|
||||
result = saveOrUpdate(stageData);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StageData queryStageDataByBizId(String bizId, int dataType) {
|
||||
return this.getOne(new LambdaQueryWrapper<StageData>().eq(StageData::getBizId, bizId).eq(StageData::getDataType, dataType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByBizId(String bizId) {
|
||||
baseMapper.delete(new LambdaQueryWrapper<StageData>().eq(StageData::getBizId, bizId));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user